Inital conversion of spv._address_of and spv.globalVariable.
In SPIR-V, the global returns a pointer, whereas in LLVM dialect the global
holds an actual value. This difference is handled by spv._address_of and
llvm.mlir.addressofops that both return a pointer. Moreover, only current
invocation is in conversion's scope.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp | ||
---|---|---|
540 | @antiagainst That's right! What about other storage classes?
This means that Private linkage should be the default for all, and it is the linkage decoration that specifies if the variable is Import/Export? |
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp | ||
---|---|---|
507 | Comment is misleading. The SPIR-V spec returns an SSA value. In SPIR-V dialect GlobalVariable is a Symbol. Not sure what LLVM dialect holds an actual value means though. AFAIK, the LLVM global variable and SPIR-V global variable are the same and the address of act the same way? | |
539 | I am confused why input is chosen as a constant. I might be missing something here (or maybe just the naming is throwing me off), but Input seems to be more like a Global Variable that is externally defined and used internally (I dont know off the top of my head if there is a further qualifier that makes it externally defined but not modified within an LLVM module). SPIR-V constants map more directly to LLVM constants. | |
mlir/test/Conversion/SPIRVToLLVM/memory-ops-to-llvm.mlir | ||
13 | Please group all the CHECK comments together. Its easier to read that way. |
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp | ||
---|---|---|
507 | spv._address_of acts the same way indeed. What I meant here is that spv.globalVariable's type is a pointer, whereas llvm.mlir.global op's type is the pointee's type. globalOp.type().cast<spirv::PointerType>().getPointeeType() to later build llvm.mlir.global. | |
539 | It is still a LLVM global but just with a constant flag. Based on LLVM dialect spec, if the global value is a constant, storing into it is not allowed. I think that by "is a constant" it means that it has a constant attribute.
per SPIR-V spec, we add constant attribute to llvm.mlir.global? |
Sorry for the delay! For future patches, please feel free to land once you've gotten Mahesh's approval; no need to wait for mine.
Comment is misleading. The SPIR-V spec returns an SSA value. In SPIR-V dialect GlobalVariable is a Symbol. Not sure what LLVM dialect holds an actual value means though. AFAIK, the LLVM global variable and SPIR-V global variable are the same and the address of act the same way?