1 #include <sys/utsname.h>
4 #include <ozulis/core/assert.hh>
5 #include <ozulis/target-data.hh>
6 #include <ozulis/target-data-factory.hh>
8 #define ADD_ALIGNMENT(Type, Size, AbiAlign, PrefAlign) \
9 data.typeAlignments.push_back( \
10 TargetData::TypeAlignment( \
11 TargetData::TypeAlignment::Type, Size, AbiAlign, PrefAlign))
16 TargetDataFactory::native()
20 const TargetData
* (*create
)();
22 {"x86_64", TargetDataFactory::amd64
},
23 {"i686", TargetDataFactory::x86
},
29 for (int i
= 0; table
[i
].machine
; i
++)
30 if (!strcmp(u
.machine
, table
[i
].machine
))
31 return table
[i
].create();
32 assert_msg(false, "unknown machine");
36 TargetDataFactory::x86()
38 static TargetData data
;
39 static bool init
= true;
45 data
.isLittleEndian
= true;
47 ADD_ALIGNMENT(Pointer
, 64, 64, 64);
49 ADD_ALIGNMENT(Integer
, 1, 8, 8);
50 ADD_ALIGNMENT(Integer
, 8, 8, 8);
51 ADD_ALIGNMENT(Integer
, 16, 16, 16);
52 ADD_ALIGNMENT(Integer
, 32, 32, 32);
53 ADD_ALIGNMENT(Integer
, 64, 32, 64);
55 ADD_ALIGNMENT(Float
, 32, 32, 32);
56 ADD_ALIGNMENT(Float
, 64, 32, 64);
57 ADD_ALIGNMENT(Float
, 80, 32, 32);
59 ADD_ALIGNMENT(Vector
, 64, 64, 64);
60 ADD_ALIGNMENT(Vector
, 128, 128, 128);
62 ADD_ALIGNMENT(Agregate
, 0, 0, 64);
68 TargetDataFactory::amd64()
70 static TargetData data
;
71 static bool init
= true;
77 data
.isLittleEndian
= true;
79 ADD_ALIGNMENT(Pointer
, 64, 64, 64);
81 ADD_ALIGNMENT(Integer
, 1, 8, 8);
82 ADD_ALIGNMENT(Integer
, 8, 8, 8);
83 ADD_ALIGNMENT(Integer
, 16, 16, 16);
84 ADD_ALIGNMENT(Integer
, 32, 32, 32);
85 ADD_ALIGNMENT(Integer
, 64, 32, 64);
87 ADD_ALIGNMENT(Float
, 32, 32, 32);
88 ADD_ALIGNMENT(Float
, 64, 32, 64);
89 ADD_ALIGNMENT(Float
, 80, 32, 32);
91 ADD_ALIGNMENT(Vector
, 64, 64, 64);
92 ADD_ALIGNMENT(Vector
, 128, 128, 128);
94 ADD_ALIGNMENT(Agregate
, 0, 0, 64);