@@ -48,7 +48,8 @@ static constexpr llvm::StringRef kMemRefCopy = "memrefCopy";
48
48
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFn (Operation *moduleOp,
49
49
StringRef name,
50
50
ArrayRef<Type> paramTypes,
51
- Type resultType, bool isVarArg, bool isReserved) {
51
+ Type resultType, bool isVarArg,
52
+ bool isReserved) {
52
53
assert (moduleOp->hasTrait <OpTrait::SymbolTable>() &&
53
54
" expected SymbolTable operation" );
54
55
auto func = llvm::dyn_cast_or_null<LLVM::LLVMFuncOp>(
@@ -58,14 +59,16 @@ LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFn(Operation *moduleOp,
58
59
if (func) {
59
60
if (funcT != func.getFunctionType ()) {
60
61
if (isReserved) {
61
- func.emitError (" redefinition of reserved function '" + name + " ' of different type " )
62
- .append (func.getFunctionType ())
63
- .append (" is prohibited" );
62
+ func.emitError (" redefinition of reserved function '" + name +
63
+ " ' of different type " )
64
+ .append (func.getFunctionType ())
65
+ .append (" is prohibited" );
64
66
exit (0 );
65
67
} else {
66
- func.emitError (" redefinition of function '" + name + " ' of different type " )
67
- .append (funcT)
68
- .append (" is prohibited" );
68
+ func.emitError (" redefinition of function '" + name +
69
+ " ' of different type " )
70
+ .append (funcT)
71
+ .append (" is prohibited" );
69
72
exit (0 );
70
73
}
71
74
}
@@ -78,39 +81,41 @@ LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFn(Operation *moduleOp,
78
81
}
79
82
80
83
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintI64Fn (Operation *moduleOp) {
81
- return lookupOrCreateFn (moduleOp, kPrintI64 ,
82
- IntegerType::get (moduleOp->getContext (), 64 ),
83
- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
84
+ return lookupOrCreateFn (
85
+ moduleOp, kPrintI64 , IntegerType::get (moduleOp->getContext (), 64 ),
86
+ LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
84
87
}
85
88
86
89
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintU64Fn (Operation *moduleOp) {
87
- return lookupOrCreateFn (moduleOp, kPrintU64 ,
88
- IntegerType::get (moduleOp->getContext (), 64 ),
89
- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
90
+ return lookupOrCreateFn (
91
+ moduleOp, kPrintU64 , IntegerType::get (moduleOp->getContext (), 64 ),
92
+ LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
90
93
}
91
94
92
95
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintF16Fn (Operation *moduleOp) {
93
96
return lookupOrCreateFn (moduleOp, kPrintF16 ,
94
97
IntegerType::get (moduleOp->getContext (), 16 ), // bits!
95
- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
98
+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
99
+ false , true );
96
100
}
97
101
98
102
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintBF16Fn (Operation *moduleOp) {
99
103
return lookupOrCreateFn (moduleOp, kPrintBF16 ,
100
104
IntegerType::get (moduleOp->getContext (), 16 ), // bits!
101
- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
105
+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
106
+ false , true );
102
107
}
103
108
104
109
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintF32Fn (Operation *moduleOp) {
105
- return lookupOrCreateFn (moduleOp, kPrintF32 ,
106
- Float32Type::get (moduleOp->getContext ()),
107
- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
110
+ return lookupOrCreateFn (
111
+ moduleOp, kPrintF32 , Float32Type::get (moduleOp->getContext ()),
112
+ LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
108
113
}
109
114
110
115
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintF64Fn (Operation *moduleOp) {
111
- return lookupOrCreateFn (moduleOp, kPrintF64 ,
112
- Float64Type::get (moduleOp->getContext ()),
113
- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
116
+ return lookupOrCreateFn (
117
+ moduleOp, kPrintF64 , Float64Type::get (moduleOp->getContext ()),
118
+ LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
114
119
}
115
120
116
121
static LLVM::LLVMPointerType getCharPtr (MLIRContext *context) {
@@ -126,39 +131,46 @@ LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintStringFn(
126
131
Operation *moduleOp, std::optional<StringRef> runtimeFunctionName) {
127
132
return lookupOrCreateFn (moduleOp, runtimeFunctionName.value_or (kPrintString ),
128
133
getCharPtr (moduleOp->getContext ()),
129
- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
134
+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
135
+ false , true );
130
136
}
131
137
132
138
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintOpenFn (Operation *moduleOp) {
133
139
return lookupOrCreateFn (moduleOp, kPrintOpen , {},
134
- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
140
+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
141
+ false , true );
135
142
}
136
143
137
144
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintCloseFn (Operation *moduleOp) {
138
145
return lookupOrCreateFn (moduleOp, kPrintClose , {},
139
- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
146
+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
147
+ false , true );
140
148
}
141
149
142
150
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintCommaFn (Operation *moduleOp) {
143
151
return lookupOrCreateFn (moduleOp, kPrintComma , {},
144
- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
152
+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
153
+ false , true );
145
154
}
146
155
147
156
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintNewlineFn (Operation *moduleOp) {
148
157
return lookupOrCreateFn (moduleOp, kPrintNewline , {},
149
- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
158
+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
159
+ false , true );
150
160
}
151
161
152
162
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateMallocFn (Operation *moduleOp,
153
163
Type indexType) {
154
164
return LLVM::lookupOrCreateFn (moduleOp, kMalloc , indexType,
155
- getVoidPtr (moduleOp->getContext ()), false , true );
165
+ getVoidPtr (moduleOp->getContext ()), false ,
166
+ true );
156
167
}
157
168
158
169
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateAlignedAllocFn (Operation *moduleOp,
159
170
Type indexType) {
160
171
return LLVM::lookupOrCreateFn (moduleOp, kAlignedAlloc , {indexType, indexType},
161
- getVoidPtr (moduleOp->getContext ()), false , true );
172
+ getVoidPtr (moduleOp->getContext ()), false ,
173
+ true );
162
174
}
163
175
164
176
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFreeFn (Operation *moduleOp) {
@@ -170,15 +182,16 @@ LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFreeFn(Operation *moduleOp) {
170
182
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateGenericAllocFn (Operation *moduleOp,
171
183
Type indexType) {
172
184
return LLVM::lookupOrCreateFn (moduleOp, kGenericAlloc , indexType,
173
- getVoidPtr (moduleOp->getContext ()), false , true );
185
+ getVoidPtr (moduleOp->getContext ()), false ,
186
+ true );
174
187
}
175
188
176
189
LLVM::LLVMFuncOp
177
190
mlir::LLVM::lookupOrCreateGenericAlignedAllocFn (Operation *moduleOp,
178
191
Type indexType) {
179
- return LLVM::lookupOrCreateFn (moduleOp, kGenericAlignedAlloc ,
180
- {indexType, indexType},
181
- getVoidPtr (moduleOp->getContext ()), false , true );
192
+ return LLVM::lookupOrCreateFn (
193
+ moduleOp, kGenericAlignedAlloc , {indexType, indexType},
194
+ getVoidPtr (moduleOp->getContext ()), false , true );
182
195
}
183
196
184
197
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateGenericFreeFn (Operation *moduleOp) {
0 commit comments