[Chapel Merge] Migrate primitive definitions to compiler/next

Branch: refs/heads/main
Revision: 4ac45a1
Author: mppf
Link: Migrate primitive definitions to compiler/next by mppf · Pull Request #18619 · chapel-lang/chapel · GitHub
Log Message:

Merge pull request #18619 from mppf/next-prim-enum

Migrate primitive definitions to compiler/next

Follow-up to PR #18172
Resolves https://github.com/Cray/chapel-private/issues/2509

PR #18172 updated the compiler/next sources to support param folding but did so in a way that used UniqueString to identify the (primitive) operator which required a lot of if/else statements checking for this or that operator. This PR changes this code to instead convert the PrimCall string to an enum element at parse time. The enum is PrimitiveTag which is based upon the existing type in the production compiler. Then, it adjusts the compiler/next/immediates/prim_data.h header to use the same numeric value as in PrimitiveTag for the same operations.

In a bit more detail here are some steps that this PR takes to do it:

  • migrates compiler/include/primitive_list.h in to compiler/next/include/chpl/uast/PrimOpsList.h and include the string name in the listing file
  • adjusted these macros to leave the PRIM_ part off of the name (it is added again when we are talking about the enum value but doesn't need to be used when creating a function - e.g. now we have codegenADD instead of codegenPRIM_ADD.
  • changed the PRIM_UNKNOWN primitives to have their own name to make primitive handling more consistent.
  • changed the ! to be named u! to be more consistent with the other unary operators
  • prim_def calls in the production compiler still provide a string name but we check that this matches the name in PrimOpsList.h

Reviewed by @dlongnecke-cray - thanks!

  • [x] full local testing

    Modified Files:
    A compiler/next/include/chpl/uast/PrimOp.h
    A compiler/next/include/chpl/uast/PrimOpsList.h
    A compiler/next/lib/uast/PrimOp.cpp
    R compiler/include/primitive_list.h
    M compiler/AST/primitive.cpp
    M compiler/codegen/cg-expr.cpp
    M compiler/include/CallExpr.h
    M compiler/include/primitive.h
    M compiler/next/include/chpl/types/Param.h
    M compiler/next/include/chpl/uast/PrimCall.h
    M compiler/next/lib/immediates/prim_data.h
    M compiler/next/lib/parsing/ParserContextImpl.h
    M compiler/next/lib/resolution/resolution-queries.cpp
    M compiler/next/lib/types/Param.cpp
    M compiler/next/lib/uast/CMakeLists.txt
    M compiler/next/lib/uast/Makefile.include
    M compiler/next/lib/uast/PrimCall.cpp
    M compiler/next/test/parsing/testParse.cpp
    M compiler/optimizations/optimizeOnClauses.cpp
    M compiler/passes/convert-uast.cpp
    M compiler/util/exprAnalysis.cpp
    M modules/internal/ChapelBase.chpl

    Compare: Comparing 0f1420d50077...4ac45a112642 · chapel-lang/chapel · GitHub