diff --git a/mlir/docs/SPIRVToLLVMDialectConversion.md b/mlir/docs/SPIRVToLLVMDialectConversion.md --- a/mlir/docs/SPIRVToLLVMDialectConversion.md +++ b/mlir/docs/SPIRVToLLVMDialectConversion.md @@ -36,7 +36,7 @@ SPIR-V Dialect | LLVM Dialect :----------------------------------: | :----------------------------------: -`vector< x >` | `!llvm<"< x >">` +`vector< x >` | `!llvm.vec< x >` ### Pointer types @@ -45,7 +45,7 @@ SPIR-V Dialect | LLVM Dialect :-------------------------------------------: | :-------------------------: -`!spv.ptr< , >` | `!llvm.element-type*` +`!spv.ptr< , >` | `!llvm.ptr<>` ### Array types @@ -59,8 +59,8 @@ SPIR-V Dialect | LLVM Dialect :-----------------------------------: | :-----------------------------------: -`!spv.array< x >`| `!llvm<"[ x ]">` -`!spv.rtarray< >` | `!llvm<"[0 x ]">` +`!spv.array< x >`| `!llvm.array< x >` +`!spv.rtarray< >` | `!llvm.array<0 x >` ### Struct types @@ -88,8 +88,8 @@ Examples of SPIR-V struct conversion are: ```mlir -!spv.struct => !llvm<"<{ i8, i32 }>"> -!spv.struct => !llvm<"{ i8, i32 }"> +!spv.struct => !llvm.struct +!spv.struct => !llvm.struct<(i8, i32)> // error !spv.struct @@ -188,11 +188,11 @@ ```mlir // Broadcasting offset - %offset0 = llvm.mlir.undef : !llvm<"<2 x i8>"> + %offset0 = llvm.mlir.undef : !llvm.vec<2 x i8> %zero = llvm.mlir.constant(0 : i32) : !llvm.i32 - %offset1 = llvm.insertelement %offset, %offset0[%zero : !llvm.i32] : !llvm<"<2 x i8>"> + %offset1 = llvm.insertelement %offset, %offset0[%zero : !llvm.i32] : !llvm.vec<2 x i8> %one = llvm.mlir.constant(1 : i32) : !llvm.i32 - %vec_offset = llvm.insertelement %offset, %offset1[%one : !llvm.i32] : !llvm<"<2 x i8>"> + %vec_offset = llvm.insertelement %offset, %offset1[%one : !llvm.i32] : !llvm.vec<2 x i8> // Broadcasting count // ... @@ -205,7 +205,7 @@ ```mlir // Zero extending offest after broadcasting - %res_offset = llvm.zext %vec_offset: !llvm<"<2 x i8>"> to !llvm<"<2 x i32>"> + %res_offset = llvm.zext %vec_offset: !llvm.vec<2 x i8> to !llvm.vec<2 x i32> ``` Also, note that if the bitwidth of `offset` or `count` is greater than the @@ -386,19 +386,19 @@ * **Aligned**: alignment is passed on to LLVM op builder, for example: ```mlir - // llvm.store %ptr, %val {alignment = 4 : i64} : !llvm<"float*"> + // llvm.store %ptr, %val {alignment = 4 : i64} : !llvm.ptr spv.Store "Function" %ptr, %val ["Aligned", 4] : f32 ``` * **None**: same case as if there is no memory access attribute. * **Nontemporal**: set `nontemporal` flag, for example: ```mlir - // %res = llvm.load %ptr {nontemporal} : !llvm<"float*"> + // %res = llvm.load %ptr {nontemporal} : !llvm.ptr %res = spv.Load "Function" %ptr ["Nontemporal"] : f32 ``` * **Volatile**: mark the op as `volatile`, for example: ```mlir - // %res = llvm.load volatile %ptr : !llvm<"float*"> + // %res = llvm.load volatile %ptr : !llvm.ptr %res = spv.Load "Function" %ptr ["Volatile"] : f32 ``` Otherwise the conversion fails as other cases (`MakePointerAvailable`, @@ -426,9 +426,9 @@ // Converted result module { - llvm.mlir.global private @struct() : !llvm<"<{ float, [10 x float] }>"> + llvm.mlir.global private @struct() : !llvm.struct llvm.func @func() { - %0 = llvm.mlir.addressof @struct : !llvm<"<{ float, [10 x float] }>*"> + %0 = llvm.mlir.addressof @struct : !llvm.ptr> llvm.return } } @@ -469,13 +469,13 @@ ```mlir // Conversion of VariableOp without initialization %size = llvm.mlir.constant(1 : i32) : !llvm.i32 -%res = spv.Variable : !spv.ptr, Function> => %res = llvm.alloca %size x !llvm<"<3 x float>"> : (!llvm.i32) -> !llvm<"<3 x float>*"> +%res = spv.Variable : !spv.ptr, Function> => %res = llvm.alloca %size x !llvm.vec<3 x float> : (!llvm.i32) -> !llvm.ptr> // Conversion of VariableOp with initialization %c = llvm.mlir.constant(0 : i64) : !llvm.i64 %c = spv.constant 0 : i64 %size = llvm.mlir.constant(1 : i32) : !llvm.i32 -%res = spv.Variable init(%c) : !spv.ptr => %res = llvm.alloca %[[SIZE]] x !llvm.i64 : (!llvm.i32) -> !llvm<"i64*"> - llvm.store %c, %res : !llvm<"i64*"> +%res = spv.Variable init(%c) : !spv.ptr => %res = llvm.alloca %[[SIZE]] x !llvm.i64 : (!llvm.i32) -> !llvm.ptr + llvm.store %c, %res : !llvm.ptr ``` Note that simple conversion to `alloca` may not be sufficent if the code has @@ -545,7 +545,7 @@ // %0 = llvm.mlir.constant(0 : i8) : !llvm.i8 %0 = spv.constant 0 : i8 -// %1 = llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi32>) : !llvm<"<3 x i32>"> +// %1 = llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi32>) : !llvm.vec<3 x i32> %1 = spv.constant dense<[2, 3, 4]> : vector<3xui32> ``` @@ -606,23 +606,23 @@ ```mlir // Conversion of selection -%cond = spv.constant true %cond = llvm.mlir.constant(true) : !llvm.i1 +%cond = spv.constant true %cond = llvm.mlir.constant(true) : !llvm.i1 spv.selection { - spv.BranchConditional %cond, ^true, ^false llvm.cond_br %cond, ^true, ^false + spv.BranchConditional %cond, ^true, ^false llvm.cond_br %cond, ^true, ^false ^true: ^true: - // True block code // True block code - spv.Branch ^merge => llvm.br ^merge + // True block code // True block code + spv.Branch ^merge => llvm.br ^merge -^false: ^false: - // False block code // False block code - spv.Branch ^merge llvm.br ^merge +^false: ^false: + // False block code // False block code + spv.Branch ^merge llvm.br ^merge -^merge: ^merge: - spv._merge llvm.br ^continue +^merge: ^merge: + spv._merge llvm.br ^continue } // Remaining code ^continue: - // Remaining code + // Remaining code ``` ```mlir