-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirBuilder.easy
147 lines (89 loc) · 6.33 KB
/
irBuilder.easy
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
IRBuilder: [{
basicBlock:;
#Memory control ops
allocOne: [1 32 IntegerType Constant AcllocateStack basicBlock.instructions.pushBack] func;
allocStack: [AcllocateStack basicBlock.instructions.pushBack] func;
allocOneAligned: [align:; 1 32 IntegerType Constant AcllocateStack dup align swap .!align basicBlock.instructions.pushBack] func;
allocStackAligned: [align:; AcllocateStack align swap .!align basicBlock.instructions.pushBack] func;
addLoad: [Load basicBlock.instructions.pushBack] func;
addLoadAligned: [align:; Load dup align swap .!align basicBlock.instructions.pushBack] func;
addStore: [Store basicBlock.instructions.pushBack] func;
addStoreAligned: [align:; Store dup align swap .!align basicBlock.instructions.pushBack] func;
addGEP: [GetElementPointer basicBlock.instructions.pushBack] func;
addPhiNode: [PhiNode basicBlock.instructions.pushBack] func;
#Terminators
addRet: [Return basicBlock.!terminator] func;
addBrUncond: [BranchUncond basicBlock.!terminator] func;
addBrCond: [BranchCond basicBlock.!terminator] func;
addSwitch: [Switch basicBlock.!terminator];
addInderectBr: [IndirectBranch basicBlock.!terminator] func;
addInvoke: [Invoke basicBlock.!terminator] func;
addUnwind: [Unwind basicBlock.!terminator] func;
addUnreachable: [Unreachable basicBlock.!terminator] func;
#Binary ops
addAdd: ["add" BinaryOperation basicBlock.instructions.pushBack] func;
addFadd: ["fadd" BinaryOperation basicBlock.instructions.pushBack] func;
addSub: ["sub" BinaryOperation basicBlock.instructions.pushBack] func;
addFsub: ["fsub" BinaryOperation basicBlock.instructions.pushBack] func;
addMul: ["mul" BinaryOperation basicBlock.instructions.pushBack] func;
addFmul: ["fmul" BinaryOperation basicBlock.instructions.pushBack] func;
addSdiv: ["sdiv" BinaryOperation basicBlock.instructions.pushBack] func;
addUdiv: ["udiv" BinaryOperation basicBlock.instructions.pushBack] func;
addFdiv: ["fdiv" BinaryOperation basicBlock.instructions.pushBack] func;
addSrem: ["srem" BinaryOperation basicBlock.instructions.pushBack] func;
addUrem: ["urem" BinaryOperation basicBlock.instructions.pushBack] func;
addFrem: ["frem" basicBlock.instructions.pushBack] func;
addFpow: ["pow" BinaryBuiltin basicBlock.instructions.pushBack] func;
#Unary ops
addFsin: ["sin" UnaryBuiltin basicBlock.instructions.pushBack] func;
addFcos: ["cos" UnaryBuiltin basicBlock.instructions.pushBack] func;
addFsqrt: ["sqrt" UnaryBuiltin basicBlock.instructions.pushBack] func;
addFceil: ["ceil" UnaryBuiltin basicBlock.instructions.pushBack] func;
addFfloor: ["floor" UnaryBuiltin basicBlock.instructions.pushBack] func;
addFlog: ["log" UnaryBuiltin basicBlock.instructions.pushBack] func;
addFlog10: ["log10" UnaryBuiltin basicBlock.instructions.pushBack] func;
#Binary bitwise ops
addShl: ["shl" BinaryOperation basicBlock.instructions.pushBack] func;
addLshr: ["lshr" BinaryOperation basicBlock.instructions.pushBack] func;
addAshr: ["ashr" BinaryOperation basicBlock.instructions.pushBack] func;
addAnd: ["and" BinaryOperation basicBlock.instructions.pushBack] func;
addOr: ["or" BinaryOperation basicBlock.instructions.pushBack] func;
addXor: ["xor" BinaryOperation basicBlock.instructions.pushBack] func;
#Conversion ops
addTrunc: ["trunc" ConversionOperation basicBlock.instructions.pushBack] func;
addTrunc: [val:type:;; val.type "INTEGER" has type "INTEGER" has and type.size val.type.size < and ~] [InvalidType] pfunc;
addZext: ["zext" ConversionOperation basicBlock.instructions.pushBack] func;
addZext: [val:type:;; val.type "INTEGER" has type "INTEGER" has and type.size val.type.size > and ~] [InvalidType] pfunc;
addSext: ["sext" ConversionOperation basicBlock.instructions.pushBack] func;
addSext: [val:type:;; val.type "INTEGER" has type "INTEGER" has and type.size val.type.size > and ~] [InvalidType] pfunc;
addFptrunc: ["fptrunc" ConversionOperation basicBlock.instructions.pushBack] func;
addFptrunc: [val:type:;; val.type "FLOAT" has type "FLOAT" has and type.size val.type.size < and ~] [InvalidType] pfunc;
addFpext: ["fpext" ConversionOperation basicBlock.instructions.pushBack] func;
addFpext: [val:type:;; val.type "FLOAT" has type "FLOAT" has and type.size val.type.size > and ~] [InvalidType] pfunc;
addFptoui: ["fptoui" ConversionOperation basicBlock.instructions.pushBack] func;
addFptoui: [val:type:;; val.type "FLOAT" has type "INTEGER" has ~] [InvalidType] pfunc;
addFptosi: ["fptosi" ConversionOperation basicBlock.instructions.pushBack] func;
addFptosi: [val:type:;; val.type "FLOAT" has type "INTEGER" has ~] [InvalidType] pfunc;
addUitofp: ["uitofp" ConversionOperation basicBlock.instructions.pushBack] func;
addUitofp: [val:type:;; val.type "INTEGER" has type "FLOAT" has ~] [InvalidType] pfunc;
addSitofp: ["sitofp" ConversionOperation basicBlock.instructions.pushBack] func;
addSitofp: [val:type:;; val.type "INTEGER" has type "FLOAT" has ~] [InvalidType] pfunc;
addPtrtoint: ["ptrtoint" ConversionOperation basicBlock.instructions.pushBack] func;
addPtrtoint: [val:type:;; val.type "POINTER" has type "INTEGER" has ~] [InvalidType] pfunc;
addInttoptr: ["inttoptr" ConversionOperation basicBlock.instructions.pushBack] func;
addInttoptr: [val:type:;; val.type "INTEGER" has type "POINTER" has ~] [InvalidType] pfunc;
addBitcast: ["bitcast" ConversionOperation basicBlock.instructions.pushBack] func;
#aggregate
addExtractValue: [ExtractValue basicBlock.instructions.pushBack] func;
addExtractValue: [fieldCount 1 <] [InvalidIndicies] pfunc;
addInsertValue: [InsertValue basicBlock.instructions.pushBack] func;
#other
addCall: [ReturningCall basicBlock.instructions.pushBack] func;
addCall: [drop .retType VoidType =] [VoidCall basicBlock.instructions.pushBack] pfunc;
addCall: [drop .type "POINTER" has] [function:args:;; function.type.type "FUNCTION" has ~ [NonFunctionCall] when
function args PointerCall basicBlock.instructions.pushBack] pfunc;
addICmp: [IntegerCompare basicBlock.instructions.pushBack] func;
addFCmp: [FloatCompare basicBlock.instructions.pushBack] func;
addSelect: [Select basicBlock.instructions.pushBack] func;
}
] func;