|
29 | 29 | using namespace mlir; |
30 | 30 | using namespace mlir::triton; |
31 | 31 |
|
| 32 | +namespace mlir::LLVM { |
| 33 | +using namespace mlir::triton; |
| 34 | + |
| 35 | +Value createConstantI1(Location loc, OpBuilder &rewriter, bool v); |
| 36 | +Value createConstantI32(Location loc, OpBuilder &rewriter, int32_t v); |
| 37 | +Value createConstantI64(Location loc, OpBuilder &rewriter, int64_t v); |
| 38 | +Value createConstantF16(Location loc, OpBuilder &rewriter, float v); |
| 39 | +Value createConstantBF16(Location loc, OpBuilder &rewriter, float v); |
| 40 | +Value createConstantF32(Location loc, OpBuilder &rewriter, float v); |
| 41 | +Value createConstantF64(Location loc, OpBuilder &rewriter, double v); |
| 42 | +Value createNaNConstant(Location loc, OpBuilder &rewriter, Type type); |
| 43 | +Value createIndexConstant(OpBuilder &builder, Location loc, |
| 44 | + const TypeConverter *converter, int64_t value); |
| 45 | +Value createLLVMIntegerConstant(OpBuilder &builder, Location loc, short width, |
| 46 | + int64_t value); |
| 47 | + |
| 48 | +LLVM::CallOp createLLVMCallOp(OpBuilder &builder, Location loc, |
| 49 | + LLVMFuncOp funcOp, ValueRange args); |
| 50 | +LLVM::CallIntrinsicOp |
| 51 | +createLLVMIntrinsicCallOp(OpBuilder &builder, Location loc, StringRef intrinsic, |
| 52 | + TypeRange types, ValueRange args); |
| 53 | +} // namespace mlir::LLVM |
| 54 | + |
| 55 | +// Is v an integer or floating-point scalar constant equal to 0? |
| 56 | +bool isConstantZero(Value v); |
| 57 | + |
32 | 58 | namespace mlir::triton { |
33 | 59 |
|
34 | 60 | // Returns CTA level thread idx |
@@ -248,26 +274,15 @@ struct TritonLLVMOpBuilder { |
248 | 274 | Value i1_val(int64_t val) { return int_val(1, val); } |
249 | 275 | Value true_val() { return int_val(1, true); } |
250 | 276 | Value false_val() { return int_val(1, false); } |
251 | | - Value f16_val(float v) { |
252 | | - auto type = type::f16Ty(builder->getContext()); |
253 | | - return builder->create<LLVM::ConstantOp>(loc, type, |
254 | | - builder->getF16FloatAttr(v)); |
255 | | - } |
256 | | - Value f32_val(float v) { |
257 | | - auto type = type::f32Ty(builder->getContext()); |
258 | | - return builder->create<LLVM::ConstantOp>(loc, type, |
259 | | - builder->getF32FloatAttr(v)); |
260 | | - } |
261 | | - Value f64_val(double v) { |
262 | | - auto type = type::f64Ty(builder->getContext()); |
263 | | - return builder->create<LLVM::ConstantOp>(loc, type, |
264 | | - builder->getF64FloatAttr(v)); |
265 | | - } |
| 277 | + Value f16_val(float v) { return LLVM::createConstantF16(loc, *builder, v); } |
| 278 | + Value bf16_val(float v) { return LLVM::createConstantBF16(loc, *builder, v); } |
| 279 | + Value f32_val(float v) { return LLVM::createConstantF32(loc, *builder, v); } |
| 280 | + Value f64_val(double v) { return LLVM::createConstantF64(loc, *builder, v); } |
266 | 281 | Value i8_val(int64_t val) { return int_val(8, val); } |
267 | 282 | Value i16_val(int64_t val) { return int_val(16, val); } |
268 | 283 | Value i32_val(int64_t val) { return int_val(32, val); } |
269 | 284 | Value i64_val(int64_t val) { return int_val(64, val); } |
270 | | - Value tid_val() { return getThreadId(*this->builder, loc); } |
| 285 | + Value tid_val() { return getThreadId(*builder, loc); } |
271 | 286 |
|
272 | 287 | Location loc; |
273 | 288 | OpBuilder *builder; |
@@ -375,24 +390,6 @@ LLVM::LLVMFuncOp appendOrGetExternFuncOp(RewriterBase &rewriter, Operation *op, |
375 | 390 | namespace LLVM { |
376 | 391 | using namespace mlir::triton; |
377 | 392 |
|
378 | | -Value createConstantI1(Location loc, OpBuilder &rewriter, bool v); |
379 | | -Value createConstantI32(Location loc, OpBuilder &rewriter, int32_t v); |
380 | | -Value createConstantI64(Location loc, OpBuilder &rewriter, int64_t v); |
381 | | -Value createConstantF16(Location loc, OpBuilder &rewriter, float v); |
382 | | -Value createConstantF32(Location loc, OpBuilder &rewriter, float v); |
383 | | -Value createConstantF64(Location loc, OpBuilder &rewriter, double v); |
384 | | -Value createNaNConstant(Location loc, OpBuilder &rewriter, Type type); |
385 | | -Value createIndexConstant(OpBuilder &builder, Location loc, |
386 | | - const TypeConverter *converter, int64_t value); |
387 | | -Value createLLVMIntegerConstant(OpBuilder &builder, Location loc, short width, |
388 | | - int64_t value); |
389 | | - |
390 | | -LLVM::CallOp createLLVMCallOp(OpBuilder &builder, Location loc, |
391 | | - LLVMFuncOp funcOp, ValueRange args); |
392 | | -LLVM::CallIntrinsicOp |
393 | | -createLLVMIntrinsicCallOp(OpBuilder &builder, Location loc, StringRef intrinsic, |
394 | | - TypeRange types, ValueRange args); |
395 | | - |
396 | 393 | // Is v an integer or floating-point scalar constant equal to 0? |
397 | 394 | bool isConstantZero(Value v); |
398 | 395 |
|
|
0 commit comments