@@ -48,7 +48,8 @@ static constexpr llvm::StringRef kMemRefCopy = "memrefCopy";
4848LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFn (Operation *moduleOp,
4949 StringRef name,
5050 ArrayRef<Type> paramTypes,
51- Type resultType, bool isVarArg, bool isReserved) {
51+ Type resultType, bool isVarArg,
52+ bool isReserved) {
5253 assert (moduleOp->hasTrait <OpTrait::SymbolTable>() &&
5354 " expected SymbolTable operation" );
5455 auto func = llvm::dyn_cast_or_null<LLVM::LLVMFuncOp>(
@@ -58,14 +59,16 @@ LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFn(Operation *moduleOp,
5859 if (func) {
5960 if (funcT != func.getFunctionType ()) {
6061 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" );
6466 exit (0 );
6567 } 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" );
6972 exit (0 );
7073 }
7174 }
@@ -78,39 +81,41 @@ LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFn(Operation *moduleOp,
7881}
7982
8083LLVM::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 );
8487}
8588
8689LLVM::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 );
9093}
9194
9295LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintF16Fn (Operation *moduleOp) {
9396 return lookupOrCreateFn (moduleOp, kPrintF16 ,
9497 IntegerType::get (moduleOp->getContext (), 16 ), // bits!
95- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
98+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
99+ false , true );
96100}
97101
98102LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintBF16Fn (Operation *moduleOp) {
99103 return lookupOrCreateFn (moduleOp, kPrintBF16 ,
100104 IntegerType::get (moduleOp->getContext (), 16 ), // bits!
101- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
105+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
106+ false , true );
102107}
103108
104109LLVM::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 );
108113}
109114
110115LLVM::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 );
114119}
115120
116121static LLVM::LLVMPointerType getCharPtr (MLIRContext *context) {
@@ -126,39 +131,46 @@ LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintStringFn(
126131 Operation *moduleOp, std::optional<StringRef> runtimeFunctionName) {
127132 return lookupOrCreateFn (moduleOp, runtimeFunctionName.value_or (kPrintString ),
128133 getCharPtr (moduleOp->getContext ()),
129- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
134+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
135+ false , true );
130136}
131137
132138LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintOpenFn (Operation *moduleOp) {
133139 return lookupOrCreateFn (moduleOp, kPrintOpen , {},
134- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
140+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
141+ false , true );
135142}
136143
137144LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintCloseFn (Operation *moduleOp) {
138145 return lookupOrCreateFn (moduleOp, kPrintClose , {},
139- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
146+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
147+ false , true );
140148}
141149
142150LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintCommaFn (Operation *moduleOp) {
143151 return lookupOrCreateFn (moduleOp, kPrintComma , {},
144- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
152+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
153+ false , true );
145154}
146155
147156LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintNewlineFn (Operation *moduleOp) {
148157 return lookupOrCreateFn (moduleOp, kPrintNewline , {},
149- LLVM::LLVMVoidType::get (moduleOp->getContext ()), false , true );
158+ LLVM::LLVMVoidType::get (moduleOp->getContext ()),
159+ false , true );
150160}
151161
152162LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateMallocFn (Operation *moduleOp,
153163 Type indexType) {
154164 return LLVM::lookupOrCreateFn (moduleOp, kMalloc , indexType,
155- getVoidPtr (moduleOp->getContext ()), false , true );
165+ getVoidPtr (moduleOp->getContext ()), false ,
166+ true );
156167}
157168
158169LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateAlignedAllocFn (Operation *moduleOp,
159170 Type indexType) {
160171 return LLVM::lookupOrCreateFn (moduleOp, kAlignedAlloc , {indexType, indexType},
161- getVoidPtr (moduleOp->getContext ()), false , true );
172+ getVoidPtr (moduleOp->getContext ()), false ,
173+ true );
162174}
163175
164176LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFreeFn (Operation *moduleOp) {
@@ -170,15 +182,16 @@ LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFreeFn(Operation *moduleOp) {
170182LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateGenericAllocFn (Operation *moduleOp,
171183 Type indexType) {
172184 return LLVM::lookupOrCreateFn (moduleOp, kGenericAlloc , indexType,
173- getVoidPtr (moduleOp->getContext ()), false , true );
185+ getVoidPtr (moduleOp->getContext ()), false ,
186+ true );
174187}
175188
176189LLVM::LLVMFuncOp
177190mlir::LLVM::lookupOrCreateGenericAlignedAllocFn (Operation *moduleOp,
178191 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 );
182195}
183196
184197LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateGenericFreeFn (Operation *moduleOp) {
0 commit comments