-
-
Notifications
You must be signed in to change notification settings - Fork 259
/
target.cpp
51 lines (42 loc) · 1.24 KB
/
target.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//===-- target.cpp -------------------------------------------------------===//
//
// LDC – the LLVM D compiler
//
// This file is distributed under the BSD-style LDC license. See the LICENSE
// file for details.
//
//===----------------------------------------------------------------------===//
#include <assert.h>
#include "target.h"
#include "gen/irstate.h"
#include "mars.h"
#include "mtype.h"
int Target::ptrsize;
int Target::realsize;
int Target::realpad;
int Target::realalignsize;
void Target::init()
{
ptrsize = gDataLayout->getPointerSize(ADDRESS_SPACE);
llvm::Type* real = DtoType(Type::basic[Tfloat80]);
realsize = gDataLayout->getTypeAllocSize(real);
realpad = realsize - gDataLayout->getTypeStoreSize(real);
realalignsize = gDataLayout->getABITypeAlignment(real);
}
/******************************
* Return memory alignment size of type.
*/
unsigned Target::alignsize (Type* type)
{
assert (type->isTypeBasic());
if (type->ty == Tvoid) return 1;
return gDataLayout->getABITypeAlignment(DtoType(type));
}
/******************************
* Return field alignment size of type.
*/
unsigned Target::fieldalign (Type* type)
{
// LDC_FIXME: Verify this.
return type->alignsize();
}