Skip to content

Commit

Permalink
Fix operation names conflicting with Julia keywords (#25)
Browse files Browse the repository at this point in the history
* add *all* julia keywords to `reservedKeywords` instead of just seeing as I go

* add "public" to list of reserved keywords

Co-authored-by: Paul Berg <[email protected]>

---------

Co-authored-by: Paul Berg <[email protected]>
  • Loading branch information
jumerckx and Pangoraw authored Jan 11, 2024
1 parent 5cddb37 commit 2615761
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
26 changes: 13 additions & 13 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,37 @@ target_dialects = [
("AMX.jl", "AMX/AMX.td"),
("Affine.jl", "Affine/IR/AffineOps.td"),
("Arithmetic.jl", "Arithmetic/IR/ArithmeticOps.td"),
# ("ArmNeon.jl", "ArmNeon/ArmNeon.td"),
("ArmNeon.jl", "ArmNeon/ArmNeon.td"),
("ArmSVE.jl", "ArmSVE/ArmSVE.td"),
("Async.jl", "Async/IR/AsyncOps.td"),
("Bufferization.jl", "Bufferization/IR/BufferizationOps.td"),
("Complex.jl", "Complex/IR/ComplexOps.td"),
("ControlFlow.jl", "ControlFlow/IR/ControlFlowOps.td"),
# ("DLTI.jl", "DLTI/DLTI.td"),
("DLTI.jl", "DLTI/DLTI.td"),
("EmitC.jl", "EmitC/IR/EmitC.td"),
("Func.jl", "Func/IR/FuncOps.td"),
# ("GPU.jl", "GPU/IR/GPUOps.td"),
("GPU.jl", "GPU/IR/GPUOps.td"),
("Linalg.jl", "Linalg/IR/LinalgOps.td"),
# ("LinalgStructured.jl", "Linalg/IR/LinalgStructuredOps.td"),
("LinalgStructured.jl", "Linalg/IR/LinalgStructuredOps.td"),
("LLVMIR.jl", "LLVMIR/LLVMOps.td"),
# ("MLProgram.jl", "MLProgram/IR/MLProgramOps.td"),
("MLProgram.jl", "MLProgram/IR/MLProgramOps.td"),
("Math.jl", "Math/IR/MathOps.td"),
("MemRef.jl", "MemRef/IR/MemRefOps.td"),
("NVGPU.jl", "NVGPU/IR/NVGPU.td"),
# ("OpenACC.jl", "OpenACC/OpenACCOps.td"),
# ("OpenMP.jl", "OpenMP/OpenMPOps.td"),
# ("PDL.jl", "PDL/IR/PDLOps.td"),
# ("PDLInterp.jl", "PDLInterp/IR/PDLInterpOps.td"),
("OpenACC.jl", "OpenACC/OpenACCOps.td"),
("OpenMP.jl", "OpenMP/OpenMPOps.td"),
("PDL.jl", "PDL/IR/PDLOps.td"),
("PDLInterp.jl", "PDLInterp/IR/PDLInterpOps.td"),
("Quant.jl", "Quant/QuantOps.td"),
# ("SCF.jl", "SCF/IR/SCFOps.td"),
# ("SPIRV.jl", "SPIRV/IR/SPIRVOps.td"),
("SCF.jl", "SCF/IR/SCFOps.td"),
("SPIRV.jl", "SPIRV/IR/SPIRVOps.td"),
("Shape.jl", "Shape/IR/ShapeOps.td"),
("SparseTensor.jl", "SparseTensor/IR/SparseTensorOps.td"),
("Tensor.jl", "Tensor/IR/TensorOps.td"),
# ("Tosa.jl", "Tosa/IR/TosaOps.td"),
("Tosa.jl", "Tosa/IR/TosaOps.td"),
("Transform.jl", "Transform/IR/TransformOps.td"),
("Vector.jl", "Vector/IR/VectorOps.td"),
# ("X86Vector.jl", "X86Vector/X86Vector.td"),
("X86Vector.jl", "X86Vector/X86Vector.td"),
]

for (file, path) in target_dialects
Expand Down
5 changes: 3 additions & 2 deletions deps/tblgen/jl-generators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ end

auto opname = op.getOperationName();
auto functionname = opname.substr(op.getDialectName().str().length() + 1); // get rid of "dialect." prefix.
// check if functionname colides with Julia keywords (for, return, if, continue, break, ...):
std::vector<std::string> reservedKeywords = {modulename, "for", "return", "if", "continue", "break", "module", "global"};
// check if functionname colides with Julia keywords or generated module name:
// https://docs.julialang.org/en/v1/base/base/#Keywords
std::vector<std::string> reservedKeywords = {modulename, "baremodule", "begin", "break", "catch", "const", "continue", "do", "else", "elseif", "end", "export", "false", "finally", "for", "function", "global", "if", "import", "let", "local", "macro", "module", "public", "quote", "return", "struct", "true", "try", "using", "while"};
if (std::find(reservedKeywords.begin(), reservedKeywords.end(), functionname) != reservedKeywords.end())
{
functionname = functionname + "_";
Expand Down

0 comments on commit 2615761

Please sign in to comment.