This is an archive of the discontinued LLVM Phabricator instance.

[2/11][POC][Clang][RISCV] Define RVV tuple types
ClosedPublic

Authored by eopXD on Mar 25 2023, 7:42 AM.

Details

Summary

For the cover letter of this patch-set, please checkout D146872.

Depends on D146872.

This is the 2nd patch of the patch-set. This patch originates from
D97264. This patch further allows local variable declaration and
function parameter passing by adjustment in clang lowering.

Test cases are provided to demonstrate the LLVM IR generated.

Note: This patch is currently only a proof-of-concept with only a
single RVV tuple type declared here, the rest will be added when
the concept of this patch-set is accepted.

Authored-by: eop Chen <eop.chen@sifive.com>
Co-Authored-by: Hsiangkai Wang <kai.wang@sifive.com>

Diff Detail

Event Timeline

eopXD created this revision.Mar 25 2023, 7:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2023, 7:42 AM
eopXD requested review of this revision.Mar 25 2023, 7:42 AM
eopXD updated this revision to Diff 508309.Mar 25 2023, 7:45 AM

Update code.

eopXD retitled this revision from [POC][Clang][RISCV] Define RVV tuple types to [2/N][POC][Clang][RISCV] Define RVV tuple types.Mar 25 2023, 7:59 AM
eopXD edited the summary of this revision. (Show Details)
eopXD edited the summary of this revision. (Show Details)
eopXD updated this revision to Diff 511093.Apr 5 2023, 7:17 AM

Rebase upon change of parent patch.

eopXD retitled this revision from [2/N][POC][Clang][RISCV] Define RVV tuple types to [2/11][POC][Clang][RISCV] Define RVV tuple types.Apr 10 2023, 12:47 AM
eopXD edited the summary of this revision. (Show Details)
craig.topper added inline comments.Apr 18 2023, 4:32 PM
clang/lib/CodeGen/CodeGenTypes.cpp
632

Why did this code need to move into the macro body? It was written the way it was before to avoid code duplication.

641

Can you unify tuple and non-tuple by checking Info.NumVectors != 1?

645

llvm::SmallVector<llvm::Type *, 4> EltTys(Info.NumVectors, EltTy)

eopXD updated this revision to Diff 516284.Apr 23 2023, 11:44 PM

Address comments from Craig.

eopXD marked 3 inline comments as done.Apr 23 2023, 11:44 PM
craig.topper added inline comments.Apr 26 2023, 10:25 AM
clang/lib/CodeGen/CGCall.cpp
3065

The Dstty, SrcSize and DstSize variables are unused in released builds.

3072

What are we loading here?

Is there a test for this code?

craig.topper added inline comments.Apr 26 2023, 10:27 AM
clang/include/clang/Basic/RISCVVTypes.def
151

Is this macro still needed?

eopXD updated this revision to Diff 522912.May 16 2023, 11:39 PM
eopXD marked 3 inline comments as done.

Address comments from Craig.

  • Remove unused variables that only associate with assertions.
  • Remove unused macro
clang/lib/CodeGen/CGCall.cpp
3072

You are right, should be a poison here.

Test case clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-0.c and clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-1.c covers the code here.

craig.topper added inline comments.May 17 2023, 12:26 AM
clang/lib/CodeGen/CGCall.cpp
3072

Thanks. I had tried to scan the tests to see if I could find the extra load, but I guess I missed it.

evandro removed a subscriber: evandro.May 17 2023, 3:55 PM
eopXD marked an inline comment as done.May 17 2023, 11:05 PM
eopXD added inline comments.
clang/lib/CodeGen/CGCall.cpp
3072

Marking this as done.

eopXD updated this revision to Diff 523323.May 18 2023, 4:01 AM
eopXD marked an inline comment as done.

Bump CI.

craig.topper accepted this revision.May 18 2023, 10:24 AM
craig.topper added inline comments.
clang/lib/CodeGen/CGCall.cpp
3059–3080

Can we call CGM.getDataLayout().getTypeAllocSize(STy) and check if the TypeSize returned isScalable instead of calling containsScalableVectorType?

clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-1.c
2

Do these two tests have the same content but different RUN lines? Can we merge them with 2 different RUN lines?

This revision is now accepted and ready to land.May 18 2023, 10:24 AM
craig.topper requested changes to this revision.May 18 2023, 10:24 AM
This revision now requires changes to proceed.May 18 2023, 10:24 AM
eopXD updated this revision to Diff 523446.May 18 2023, 10:39 AM
eopXD marked 2 inline comments as done.

Address comments from Craig.

clang/lib/CodeGen/CGCall.cpp
3059–3080

Switched to using CGM.getDataLayout().getTypeAllocSize(STy), though calling containsScalableVectorType won't cost too much because the function has memoization.

craig.topper added inline comments.May 18 2023, 11:54 AM
clang/lib/CodeGen/CGCall.cpp
3059–3080

Can cache GM.getDataLayout().getTypeAllocSize(STy) in a variable? We call it here and inside both the if and the else body.

eopXD updated this revision to Diff 523491.May 18 2023, 11:58 AM

Address comment from Craig.

eopXD marked an inline comment as done.May 18 2023, 11:58 AM
craig.topper added inline comments.May 18 2023, 11:59 AM
clang/lib/CodeGen/CGCall.cpp
3084–3094

This can use StructSize.getFixedValue()

eopXD updated this revision to Diff 523493.May 18 2023, 12:04 PM

Address comment from Craig.

eopXD marked an inline comment as done.May 18 2023, 12:04 PM
This revision is now accepted and ready to land.May 18 2023, 12:07 PM
eopXD updated this revision to Diff 523834.May 19 2023, 10:07 AM

Rebase to latest main before landing this.

eopXD edited the summary of this revision. (Show Details)May 19 2023, 10:31 AM
This revision was landed with ongoing or failed builds.May 22 2023, 12:50 AM
This revision was automatically updated to reflect the committed changes.
eopXD added a comment.May 22 2023, 1:18 AM

Committing this patch caused build failure in non-RISC-V buildbot CI-s because of the missing REQUIRES line in the test case clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type.c.

This is addressed in the 5a61920ed8b3e76d8f9bf39f2c1e18d552fcc976.