[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
@@ -149,6 +149,12 @@ BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") BUILTIN(__builtin_amdgcn_make_buffer_rsrc, "Qbv*sii", "nc") +BUILTIN(__builtin_amdgcn_raw_buffer_store_b8, "vcQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_b16, "vsQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_b32, "viQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_b64, "vWiQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_b96, "vV3iQbiiIi", "n") shiltian wrote: Is there any alternative (or native) way to represent `b96` other than making it a `v3i32`? https://github.com/llvm/llvm-project/pull/94576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94576 >From 7fee22e922090633e0d96bd564aefc94bde7bb72 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Fri, 21 Jun 2024 11:20:55 -0400 Subject: [PATCH 1/2] [Clang] Replace `emitXXXBuiltin` with a unified interface --- clang/lib/CodeGen/CGBuiltin.cpp | 216 +++- 1 file changed, 102 insertions(+), 114 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 2516ed4508242..891749d487d18 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -581,49 +581,19 @@ static Value *emitCallMaybeConstrainedFPBuiltin(CodeGenFunction , return CGF.Builder.CreateCall(F, Args); } -// Emit a simple mangled intrinsic that has 1 argument and a return type -// matching the argument type. -static Value *emitUnaryBuiltin(CodeGenFunction , const CallExpr *E, - unsigned IntrinsicID, - llvm::StringRef Name = "") { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, Src0, Name); -} - -// Emit an intrinsic that has 2 operands of the same type as its result. -static Value *emitBinaryBuiltin(CodeGenFunction , -const CallExpr *E, -unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, { Src0, Src1 }); -} - -// Emit an intrinsic that has 3 operands of the same type as its result. -static Value *emitTernaryBuiltin(CodeGenFunction , - const CallExpr *E, - unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 }); -} - -static Value *emitQuaternaryBuiltin(CodeGenFunction , const CallExpr *E, -unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); - llvm::Value *Src3 = CGF.EmitScalarExpr(E->getArg(3)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, {Src0, Src1, Src2, Src3}); +// Emit a simple intrinsic that has N arguments and a return type matching the +// argument type. It is assumed that only the first argument is mangled and all +// arguments are scalar expressions. +template +Value *emitBuiltinWithSingleMangling(CodeGenFunction , const CallExpr *E, + unsigned IntrinsicID, + llvm::StringRef Name = "") { + static_assert(N, "expect non-empty argument"); + SmallVector Args; + for (unsigned I = 0; I < N; ++I) +Args.push_back(CGF.EmitScalarExpr(E->getArg(I))); + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Args[0]->getType()); + return CGF.Builder.CreateCall(F, Args, Name); } // Emit an intrinsic that has 1 float or double operand, and 1 integer. @@ -2689,7 +2659,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_copysignf16: case Builtin::BI__builtin_copysignl: case Builtin::BI__builtin_copysignf128: - return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::copysign)); + return RValue::get( + emitBuiltinWithSingleMangling<2>(*this, E, Intrinsic::copysign)); case Builtin::BIcos: case Builtin::BIcosf: @@ -2734,7 +2705,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, // TODO: strictfp support if (Builder.getIsFPConstrained()) break; - return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::exp10)); + return RValue::get( + emitBuiltinWithSingleMangling<1>(*this, E, Intrinsic::exp10)); } case Builtin::BIfabs: case Builtin::BIfabsf: @@ -2744,7 +2716,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_fabsf16: case Builtin::BI__builtin_fabsl: case Builtin::BI__builtin_fabsf128: - return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::fabs)); + return RValue::get( + emitBuiltinWithSingleMangling<1>(*this, E, Intrinsic::fabs)); case Builtin::BIfloor: case Builtin::BIfloorf: @@ -3427,13 +3400,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/94576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94576 >From 7fee22e922090633e0d96bd564aefc94bde7bb72 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Fri, 21 Jun 2024 11:20:55 -0400 Subject: [PATCH 1/2] [Clang] Replace `emitXXXBuiltin` with a unified interface --- clang/lib/CodeGen/CGBuiltin.cpp | 216 +++- 1 file changed, 102 insertions(+), 114 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 2516ed4508242..891749d487d18 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -581,49 +581,19 @@ static Value *emitCallMaybeConstrainedFPBuiltin(CodeGenFunction , return CGF.Builder.CreateCall(F, Args); } -// Emit a simple mangled intrinsic that has 1 argument and a return type -// matching the argument type. -static Value *emitUnaryBuiltin(CodeGenFunction , const CallExpr *E, - unsigned IntrinsicID, - llvm::StringRef Name = "") { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, Src0, Name); -} - -// Emit an intrinsic that has 2 operands of the same type as its result. -static Value *emitBinaryBuiltin(CodeGenFunction , -const CallExpr *E, -unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, { Src0, Src1 }); -} - -// Emit an intrinsic that has 3 operands of the same type as its result. -static Value *emitTernaryBuiltin(CodeGenFunction , - const CallExpr *E, - unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 }); -} - -static Value *emitQuaternaryBuiltin(CodeGenFunction , const CallExpr *E, -unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); - llvm::Value *Src3 = CGF.EmitScalarExpr(E->getArg(3)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, {Src0, Src1, Src2, Src3}); +// Emit a simple intrinsic that has N arguments and a return type matching the +// argument type. It is assumed that only the first argument is mangled and all +// arguments are scalar expressions. +template +Value *emitBuiltinWithSingleMangling(CodeGenFunction , const CallExpr *E, + unsigned IntrinsicID, + llvm::StringRef Name = "") { + static_assert(N, "expect non-empty argument"); + SmallVector Args; + for (unsigned I = 0; I < N; ++I) +Args.push_back(CGF.EmitScalarExpr(E->getArg(I))); + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Args[0]->getType()); + return CGF.Builder.CreateCall(F, Args, Name); } // Emit an intrinsic that has 1 float or double operand, and 1 integer. @@ -2689,7 +2659,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_copysignf16: case Builtin::BI__builtin_copysignl: case Builtin::BI__builtin_copysignf128: - return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::copysign)); + return RValue::get( + emitBuiltinWithSingleMangling<2>(*this, E, Intrinsic::copysign)); case Builtin::BIcos: case Builtin::BIcosf: @@ -2734,7 +2705,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, // TODO: strictfp support if (Builder.getIsFPConstrained()) break; - return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::exp10)); + return RValue::get( + emitBuiltinWithSingleMangling<1>(*this, E, Intrinsic::exp10)); } case Builtin::BIfabs: case Builtin::BIfabsf: @@ -2744,7 +2716,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_fabsf16: case Builtin::BI__builtin_fabsl: case Builtin::BI__builtin_fabsf128: - return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::fabs)); + return RValue::get( + emitBuiltinWithSingleMangling<1>(*this, E, Intrinsic::fabs)); case Builtin::BIfloor: case Builtin::BIfloorf: @@ -3427,13 +3400,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case
[clang] [Clang] Replace `emitXXXBuiltin` with a unified interface (PR #96313)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/96313 >From bedcb3a4a1ffe958e84ed8f0bdaba59dd7bf3ef3 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Fri, 21 Jun 2024 10:45:39 -0400 Subject: [PATCH] [Clang] Replace `emitXXXBuiltin` with a unified interface --- clang/lib/CodeGen/CGBuiltin.cpp | 216 +++- 1 file changed, 102 insertions(+), 114 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 2516ed4508242..891749d487d18 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -581,49 +581,19 @@ static Value *emitCallMaybeConstrainedFPBuiltin(CodeGenFunction , return CGF.Builder.CreateCall(F, Args); } -// Emit a simple mangled intrinsic that has 1 argument and a return type -// matching the argument type. -static Value *emitUnaryBuiltin(CodeGenFunction , const CallExpr *E, - unsigned IntrinsicID, - llvm::StringRef Name = "") { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, Src0, Name); -} - -// Emit an intrinsic that has 2 operands of the same type as its result. -static Value *emitBinaryBuiltin(CodeGenFunction , -const CallExpr *E, -unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, { Src0, Src1 }); -} - -// Emit an intrinsic that has 3 operands of the same type as its result. -static Value *emitTernaryBuiltin(CodeGenFunction , - const CallExpr *E, - unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 }); -} - -static Value *emitQuaternaryBuiltin(CodeGenFunction , const CallExpr *E, -unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); - llvm::Value *Src3 = CGF.EmitScalarExpr(E->getArg(3)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, {Src0, Src1, Src2, Src3}); +// Emit a simple intrinsic that has N arguments and a return type matching the +// argument type. It is assumed that only the first argument is mangled and all +// arguments are scalar expressions. +template +Value *emitBuiltinWithSingleMangling(CodeGenFunction , const CallExpr *E, + unsigned IntrinsicID, + llvm::StringRef Name = "") { + static_assert(N, "expect non-empty argument"); + SmallVector Args; + for (unsigned I = 0; I < N; ++I) +Args.push_back(CGF.EmitScalarExpr(E->getArg(I))); + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Args[0]->getType()); + return CGF.Builder.CreateCall(F, Args, Name); } // Emit an intrinsic that has 1 float or double operand, and 1 integer. @@ -2689,7 +2659,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_copysignf16: case Builtin::BI__builtin_copysignl: case Builtin::BI__builtin_copysignf128: - return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::copysign)); + return RValue::get( + emitBuiltinWithSingleMangling<2>(*this, E, Intrinsic::copysign)); case Builtin::BIcos: case Builtin::BIcosf: @@ -2734,7 +2705,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, // TODO: strictfp support if (Builder.getIsFPConstrained()) break; - return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::exp10)); + return RValue::get( + emitBuiltinWithSingleMangling<1>(*this, E, Intrinsic::exp10)); } case Builtin::BIfabs: case Builtin::BIfabsf: @@ -2744,7 +2716,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_fabsf16: case Builtin::BI__builtin_fabsl: case Builtin::BI__builtin_fabsf128: - return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::fabs)); + return RValue::get( + emitBuiltinWithSingleMangling<1>(*this, E, Intrinsic::fabs)); case Builtin::BIfloor: case Builtin::BIfloorf: @@ -3427,13 +3400,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case
[clang] [Clang] Replace `emitXXXBuiltin` with a unified interface (PR #96313)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/96313 >From 836b7c1dce1ed323afef4d911e9c12378858e0dd Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Fri, 21 Jun 2024 10:45:04 -0400 Subject: [PATCH] [Clang] Replace `emitXXXBuiltin` with a unified interface --- clang/lib/CodeGen/CGBuiltin.cpp | 216 +++- 1 file changed, 102 insertions(+), 114 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 2516ed4508242..f89b739a10920 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -581,49 +581,19 @@ static Value *emitCallMaybeConstrainedFPBuiltin(CodeGenFunction , return CGF.Builder.CreateCall(F, Args); } -// Emit a simple mangled intrinsic that has 1 argument and a return type -// matching the argument type. -static Value *emitUnaryBuiltin(CodeGenFunction , const CallExpr *E, - unsigned IntrinsicID, - llvm::StringRef Name = "") { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, Src0, Name); -} - -// Emit an intrinsic that has 2 operands of the same type as its result. -static Value *emitBinaryBuiltin(CodeGenFunction , -const CallExpr *E, -unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, { Src0, Src1 }); -} - -// Emit an intrinsic that has 3 operands of the same type as its result. -static Value *emitTernaryBuiltin(CodeGenFunction , - const CallExpr *E, - unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 }); -} - -static Value *emitQuaternaryBuiltin(CodeGenFunction , const CallExpr *E, -unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); - llvm::Value *Src3 = CGF.EmitScalarExpr(E->getArg(3)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, {Src0, Src1, Src2, Src3}); +// Emit a simple intrinsic that has N arguments and a return type matching the +// argument type. It is assumed that only the first argument is mangled and all +// arguments are expected to be scalar expr. +template +Value *emitBuiltinWithSingleMangling(CodeGenFunction , const CallExpr *E, + unsigned IntrinsicID, + llvm::StringRef Name = "") { + static_assert(N, "expect non-empty argument"); + SmallVector Args; + for (unsigned I = 0; I < N; ++I) +Args.push_back(CGF.EmitScalarExpr(E->getArg(I))); + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Args[0]->getType()); + return CGF.Builder.CreateCall(F, Args, Name); } // Emit an intrinsic that has 1 float or double operand, and 1 integer. @@ -2689,7 +2659,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_copysignf16: case Builtin::BI__builtin_copysignl: case Builtin::BI__builtin_copysignf128: - return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::copysign)); + return RValue::get( + emitBuiltinWithSingleMangling<2>(*this, E, Intrinsic::copysign)); case Builtin::BIcos: case Builtin::BIcosf: @@ -2734,7 +2705,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, // TODO: strictfp support if (Builder.getIsFPConstrained()) break; - return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::exp10)); + return RValue::get( + emitBuiltinWithSingleMangling<1>(*this, E, Intrinsic::exp10)); } case Builtin::BIfabs: case Builtin::BIfabsf: @@ -2744,7 +2716,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_fabsf16: case Builtin::BI__builtin_fabsl: case Builtin::BI__builtin_fabsf128: - return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::fabs)); + return RValue::get( + emitBuiltinWithSingleMangling<1>(*this, E, Intrinsic::fabs)); case Builtin::BIfloor: case Builtin::BIfloorf: @@ -3427,13 +3400,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case
[clang] [Clang] Replace `emitXXXBuiltin` with a unified interface (PR #96313)
https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/96313 None >From 64dbea02a0946dba55dad63b930939ed08907e8a Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Fri, 21 Jun 2024 10:43:11 -0400 Subject: [PATCH] [Clang] Replace `emitXXXBuiltin` with a unified interface --- clang/lib/CodeGen/CGBuiltin.cpp | 216 +++- 1 file changed, 102 insertions(+), 114 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 2516ed4508242..e844a3643897a 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -581,49 +581,19 @@ static Value *emitCallMaybeConstrainedFPBuiltin(CodeGenFunction , return CGF.Builder.CreateCall(F, Args); } -// Emit a simple mangled intrinsic that has 1 argument and a return type -// matching the argument type. -static Value *emitUnaryBuiltin(CodeGenFunction , const CallExpr *E, - unsigned IntrinsicID, - llvm::StringRef Name = "") { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, Src0, Name); -} - -// Emit an intrinsic that has 2 operands of the same type as its result. -static Value *emitBinaryBuiltin(CodeGenFunction , -const CallExpr *E, -unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, { Src0, Src1 }); -} - -// Emit an intrinsic that has 3 operands of the same type as its result. -static Value *emitTernaryBuiltin(CodeGenFunction , - const CallExpr *E, - unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 }); -} - -static Value *emitQuaternaryBuiltin(CodeGenFunction , const CallExpr *E, -unsigned IntrinsicID) { - llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); - llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); - llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); - llvm::Value *Src3 = CGF.EmitScalarExpr(E->getArg(3)); - - Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); - return CGF.Builder.CreateCall(F, {Src0, Src1, Src2, Src3}); +// Emit a simple intrinsic that has N argument and a return type matching the +// argument type. It is assumed that only the first argument is mangled and all +// arguments are expected to be scalar expr. +template +Value *emitBuiltinWithSingleMangling(CodeGenFunction , const CallExpr *E, + unsigned IntrinsicID, + llvm::StringRef Name = "") { + static_assert(N, "expect non-empty argument"); + SmallVector Args; + for (unsigned I = 0; I < N; ++I) +Args.push_back(CGF.EmitScalarExpr(E->getArg(I))); + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Args[0]->getType()); + return CGF.Builder.CreateCall(F, Args, Name); } // Emit an intrinsic that has 1 float or double operand, and 1 integer. @@ -2689,7 +2659,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_copysignf16: case Builtin::BI__builtin_copysignl: case Builtin::BI__builtin_copysignf128: - return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::copysign)); + return RValue::get( + emitBuiltinWithSingleMangling<2>(*this, E, Intrinsic::copysign)); case Builtin::BIcos: case Builtin::BIcosf: @@ -2734,7 +2705,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, // TODO: strictfp support if (Builder.getIsFPConstrained()) break; - return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::exp10)); + return RValue::get( + emitBuiltinWithSingleMangling<1>(*this, E, Intrinsic::exp10)); } case Builtin::BIfabs: case Builtin::BIfabsf: @@ -2744,7 +2716,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_fabsf16: case Builtin::BI__builtin_fabsl: case Builtin::BI__builtin_fabsf128: - return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::fabs)); + return RValue::get( + emitBuiltinWithSingleMangling<1>(*this, E, Intrinsic::fabs)); case Builtin::BIfloor: case Builtin::BIfloorf: @@ -3427,13 +3400,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
@@ -149,6 +149,19 @@ BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") BUILTIN(__builtin_amdgcn_make_buffer_rsrc, "Qbv*sii", "nc") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i8, "vcQbiiIi", "n") shiltian wrote: The current variants don't have v16 version anyway. I think it might be more reasonable to provide the actual low level thingy to users and they need to take care of types, since we never know what kind of types there will be. https://github.com/llvm/llvm-project/pull/94576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
@@ -149,6 +149,19 @@ BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") BUILTIN(__builtin_amdgcn_make_buffer_rsrc, "Qbv*sii", "nc") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i8, "vcQbiiIi", "n") shiltian wrote: > Probably should drop the _ptr part of the name. This was more of a legacy > issue in the intrinsic case, since the resource-as-vector case already took > the name. Sure, can do. > Also not sure if we should follow the naming convention of the instruction > instead (probably the gfx12 one?). you mean things like `buffer_store_b8`? In this way, we don't need to differentiate types, just bit size. https://github.com/llvm/llvm-project/pull/94576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
@@ -626,6 +626,18 @@ static Value *emitQuaternaryBuiltin(CodeGenFunction , const CallExpr *E, return CGF.Builder.CreateCall(F, {Src0, Src1, Src2, Src3}); } +static Value *emitQuinaryBuiltin(CodeGenFunction , const CallExpr *E, shiltian wrote: If we look at existing `emitXXXBuiltin` (ignore quaternary one which was added by me), it looks like `XXX` means the number of arguments we have for the builtin, and all of them just have single mangling. I think a better unified function signature might be `template void emitBuiltinWithSingleMangling` but it is out of the scope. I can do it in a separate patch. https://github.com/llvm/llvm-project/pull/94576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94576 >From 01443b5f9d0b8d96b1d9e874d08c0464e9114502 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Thu, 20 Jun 2024 12:35:35 -0400 Subject: [PATCH] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` --- clang/include/clang/Basic/BuiltinsAMDGPU.def | 13 + clang/lib/CodeGen/CGBuiltin.cpp | 26 ++ .../builtins-amdgcn-raw-ptr-buffer-store.cl | 248 ++ ...ltins-amdgcn-raw-ptr-buffer-store-error.cl | 67 + 4 files changed, 354 insertions(+) create mode 100644 clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl create mode 100644 clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-store-error.cl diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index a73e63355cfd7..eceda9f2fe15b 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -149,6 +149,19 @@ BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") BUILTIN(__builtin_amdgcn_make_buffer_rsrc, "Qbv*sii", "nc") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i8, "vcQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i16, "vsQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i32, "viQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_f16, "vhQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_f32, "vfQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2i16, "vV2sQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2i32, "vV2iQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2f16, "vV2hQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2f32, "vV2fQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4i16, "vV4sQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4i32, "vV4iQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4f16, "vV4hQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4f32, "vV4fQbiiIi", "n") //===--===// // Ballot builtins. diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 931726a78dae9..fbb7da84b12fc 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -626,6 +626,18 @@ static Value *emitQuaternaryBuiltin(CodeGenFunction , const CallExpr *E, return CGF.Builder.CreateCall(F, {Src0, Src1, Src2, Src3}); } +static Value *emitQuinaryBuiltin(CodeGenFunction , const CallExpr *E, + unsigned IntrinsicID) { + llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); + llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); + llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); + llvm::Value *Src3 = CGF.EmitScalarExpr(E->getArg(3)); + llvm::Value *Src4 = CGF.EmitScalarExpr(E->getArg(4)); + + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + return CGF.Builder.CreateCall(F, {Src0, Src1, Src2, Src3, Src4}); +} + // Emit an intrinsic that has 1 float or double operand, and 1 integer. static Value *emitFPIntBuiltin(CodeGenFunction , const CallExpr *E, @@ -19121,6 +19133,20 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, } case AMDGPU::BI__builtin_amdgcn_make_buffer_rsrc: return emitQuaternaryBuiltin(*this, E, Intrinsic::amdgcn_make_buffer_rsrc); + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_i8: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_i16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_i32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_f32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_f16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2i16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2i32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2f16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2f32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4i16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4i32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4f16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4f32: +return emitQuinaryBuiltin(*this, E, Intrinsic::amdgcn_raw_ptr_buffer_store); default: return nullptr; } diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl new file mode 100644 index 0..3f655617f6684 --- /dev/null +++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl @@ -0,0 +1,248 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
shiltian wrote: > maybe add a test for non-constant offset? Hmm, I thought I added all tests...My bad. Will add it right away. https://github.com/llvm/llvm-project/pull/94576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for `llvm.amdgcn.make.buffer.rsrc` intrinsic (PR #95276)
https://github.com/shiltian closed https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
shiltian wrote: ping https://github.com/llvm/llvm-project/pull/94576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for `llvm.amdgcn.make.buffer.rsrc` intrinsic (PR #95276)
shiltian wrote: ping https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [OpenMP] OpenMP 5.1 "assume" directive parsing support (PR #92731)
@@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -ast-print %s | FileCheck %s +// expected-no-diagnostics + +extern int bar(int); + +int foo(int arg) +{ + #pragma omp assume no_openmp_routines + { +auto fn = [](int x) { return bar(x); }; +// CHECK: auto fn = [](int x) { +return fn(5); + } +} + +class C { +public: + int foo(int a); +}; + +// We're really just checking that this parses. All the assumptions are thrown +// away immediately for now. +int C::foo(int a) +{ + #pragma omp assume holds(sizeof(T) == 8) absent(parallel) + { +auto fn = [](int x) { return bar(x); }; +// CHECK: auto fn = [](int x) { +return fn(5); + } +} shiltian wrote: empty line EoF https://github.com/llvm/llvm-project/pull/92731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [OpenMP] OpenMP 5.1 "assume" directive parsing support (PR #92731)
@@ -0,0 +1,42 @@ +// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s +// expected-no-diagnostics + +#ifndef HEADER +#define HEADER + +extern int qux(int); + +template +int foo(T arg) +{ + #pragma omp assume no_openmp_routines + { +auto fn = [](int x) { return qux(x); }; +// CHECK: auto fn = [](int x) { +return fn(5); + } +} + +template +class C { + T m; + +public: + T bar(T a); +}; + +// We're really just checking this parses. All the assumptions are thrown +// away immediately for now. +template +T C::bar(T a) +{ + #pragma omp assume holds(sizeof(T) == 8) absent(parallel) + { +return (T)qux((int)a); +// CHECK: return (T)qux((int)a); + } +} + +#endif shiltian wrote: ditto https://github.com/llvm/llvm-project/pull/92731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [OpenMP] OpenMP 5.1 "assume" directive parsing support (PR #92731)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/92731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [OpenMP] OpenMP 5.1 "assume" directive parsing support (PR #92731)
https://github.com/shiltian commented: don't you need more code in AST? https://github.com/llvm/llvm-project/pull/92731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94576 >From b63209bfc103e2606afecd00ef10cf843c37fb2b Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Tue, 18 Jun 2024 20:50:16 -0400 Subject: [PATCH 1/2] [Clang][AMDGPU] Add a builtin for `llvm.amdgcn.make.buffer.rsrc` intrinsic Depends on #94830. --- clang/include/clang/Basic/Builtins.def| 1 + clang/include/clang/Basic/BuiltinsAMDGPU.def | 2 + clang/lib/AST/ASTContext.cpp | 4 + clang/lib/CodeGen/CGBuiltin.cpp | 13 +++ .../CodeGenHIP/builtins-make-buffer-rsrc.hip | 105 ++ .../builtins-amdgcn-make-buffer-rsrc.cl | 93 6 files changed, 218 insertions(+) create mode 100644 clang/test/CodeGenHIP/builtins-make-buffer-rsrc.hip create mode 100644 clang/test/CodeGenOpenCL/builtins-amdgcn-make-buffer-rsrc.cl diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def index f356f881d5ef9..d2d500c990b99 100644 --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/include/clang/Basic/Builtins.def @@ -33,6 +33,7 @@ // q -> Scalable vector, followed by the number of elements and the base type. // Q -> target builtin type, followed by a character to distinguish the builtin type //Qa -> AArch64 svcount_t builtin type. +//Qb -> AMDGPU __amdgpu_buffer_rsrc_t builtin type. // E -> ext_vector, followed by the number of elements and the base type. // X -> _Complex, followed by the base type. // Y -> ptrdiff_t diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 9e6800ea814a0..a73e63355cfd7 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -148,6 +148,8 @@ BUILTIN(__builtin_amdgcn_qsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") +BUILTIN(__builtin_amdgcn_make_buffer_rsrc, "Qbv*sii", "nc") + //===--===// // Ballot builtins. //===--===// diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index a4e6d3b108c8a..fa12802c8cc34 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -11546,6 +11546,10 @@ static QualType DecodeTypeFromStr(const char *, const ASTContext , Type = Context.SveCountTy; break; } +case 'b': { + Type = Context.AMDGPUBufferRsrcTy; + break; +} default: llvm_unreachable("Unexpected target builtin type"); } diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 08a89bd123d03..51b182080f0fc 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -615,6 +615,17 @@ static Value *emitTernaryBuiltin(CodeGenFunction , return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 }); } +static Value *emitQuaternaryBuiltin(CodeGenFunction , const CallExpr *E, +unsigned IntrinsicID) { + llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); + llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); + llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); + llvm::Value *Src3 = CGF.EmitScalarExpr(E->getArg(3)); + + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + return CGF.Builder.CreateCall(F, {Src0, Src1, Src2, Src3}); +} + // Emit an intrinsic that has 1 float or double operand, and 1 integer. static Value *emitFPIntBuiltin(CodeGenFunction , const CallExpr *E, @@ -19111,6 +19122,8 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, CGM.getIntrinsic(Intrinsic::amdgcn_s_sendmsg_rtn, {ResultType}); return Builder.CreateCall(F, {Arg}); } + case AMDGPU::BI__builtin_amdgcn_make_buffer_rsrc: +return emitQuaternaryBuiltin(*this, E, Intrinsic::amdgcn_make_buffer_rsrc); default: return nullptr; } diff --git a/clang/test/CodeGenHIP/builtins-make-buffer-rsrc.hip b/clang/test/CodeGenHIP/builtins-make-buffer-rsrc.hip new file mode 100644 index 0..c1a30633f3d0a --- /dev/null +++ b/clang/test/CodeGenHIP/builtins-make-buffer-rsrc.hip @@ -0,0 +1,105 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu verde -emit-llvm -disable-llvm-optzns -fcuda-is-device -o - %s | FileCheck %s + +#define __device__ __attribute__((device)) + +// CHECK-LABEL: define dso_local ptr addrspace(8) @_Z31test_amdgcn_make_buffer_rsrc_p0Pvsii( +// CHECK-SAME: ptr noundef [[P:%.*]], i16 noundef signext [[STRIDE:%.*]], i32 noundef [[NUM:%.*]], i32 noundef [[FLAGS:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT:
[clang] [Clang][AMDGPU] Add a builtin for `llvm.amdgcn.make.buffer.rsrc` intrinsic (PR #95276)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94576 >From b63209bfc103e2606afecd00ef10cf843c37fb2b Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Tue, 18 Jun 2024 20:50:16 -0400 Subject: [PATCH 1/2] [Clang][AMDGPU] Add a builtin for `llvm.amdgcn.make.buffer.rsrc` intrinsic Depends on #94830. --- clang/include/clang/Basic/Builtins.def| 1 + clang/include/clang/Basic/BuiltinsAMDGPU.def | 2 + clang/lib/AST/ASTContext.cpp | 4 + clang/lib/CodeGen/CGBuiltin.cpp | 13 +++ .../CodeGenHIP/builtins-make-buffer-rsrc.hip | 105 ++ .../builtins-amdgcn-make-buffer-rsrc.cl | 93 6 files changed, 218 insertions(+) create mode 100644 clang/test/CodeGenHIP/builtins-make-buffer-rsrc.hip create mode 100644 clang/test/CodeGenOpenCL/builtins-amdgcn-make-buffer-rsrc.cl diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def index f356f881d5ef9..d2d500c990b99 100644 --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/include/clang/Basic/Builtins.def @@ -33,6 +33,7 @@ // q -> Scalable vector, followed by the number of elements and the base type. // Q -> target builtin type, followed by a character to distinguish the builtin type //Qa -> AArch64 svcount_t builtin type. +//Qb -> AMDGPU __amdgpu_buffer_rsrc_t builtin type. // E -> ext_vector, followed by the number of elements and the base type. // X -> _Complex, followed by the base type. // Y -> ptrdiff_t diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 9e6800ea814a0..a73e63355cfd7 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -148,6 +148,8 @@ BUILTIN(__builtin_amdgcn_qsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") +BUILTIN(__builtin_amdgcn_make_buffer_rsrc, "Qbv*sii", "nc") + //===--===// // Ballot builtins. //===--===// diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index a4e6d3b108c8a..fa12802c8cc34 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -11546,6 +11546,10 @@ static QualType DecodeTypeFromStr(const char *, const ASTContext , Type = Context.SveCountTy; break; } +case 'b': { + Type = Context.AMDGPUBufferRsrcTy; + break; +} default: llvm_unreachable("Unexpected target builtin type"); } diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 08a89bd123d03..51b182080f0fc 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -615,6 +615,17 @@ static Value *emitTernaryBuiltin(CodeGenFunction , return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 }); } +static Value *emitQuaternaryBuiltin(CodeGenFunction , const CallExpr *E, +unsigned IntrinsicID) { + llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); + llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); + llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); + llvm::Value *Src3 = CGF.EmitScalarExpr(E->getArg(3)); + + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + return CGF.Builder.CreateCall(F, {Src0, Src1, Src2, Src3}); +} + // Emit an intrinsic that has 1 float or double operand, and 1 integer. static Value *emitFPIntBuiltin(CodeGenFunction , const CallExpr *E, @@ -19111,6 +19122,8 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, CGM.getIntrinsic(Intrinsic::amdgcn_s_sendmsg_rtn, {ResultType}); return Builder.CreateCall(F, {Arg}); } + case AMDGPU::BI__builtin_amdgcn_make_buffer_rsrc: +return emitQuaternaryBuiltin(*this, E, Intrinsic::amdgcn_make_buffer_rsrc); default: return nullptr; } diff --git a/clang/test/CodeGenHIP/builtins-make-buffer-rsrc.hip b/clang/test/CodeGenHIP/builtins-make-buffer-rsrc.hip new file mode 100644 index 0..c1a30633f3d0a --- /dev/null +++ b/clang/test/CodeGenHIP/builtins-make-buffer-rsrc.hip @@ -0,0 +1,105 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu verde -emit-llvm -disable-llvm-optzns -fcuda-is-device -o - %s | FileCheck %s + +#define __device__ __attribute__((device)) + +// CHECK-LABEL: define dso_local ptr addrspace(8) @_Z31test_amdgcn_make_buffer_rsrc_p0Pvsii( +// CHECK-SAME: ptr noundef [[P:%.*]], i16 noundef signext [[STRIDE:%.*]], i32 noundef [[NUM:%.*]], i32 noundef [[FLAGS:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT:
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/95276 >From 5bf43d825870999bbb762304e6f407bd0ce1403b Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Tue, 18 Jun 2024 20:49:44 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a builtin for `llvm.amdgcn.make.buffer.rsrc` intrinsic Depends on #94830. --- clang/include/clang/Basic/Builtins.def| 1 + clang/include/clang/Basic/BuiltinsAMDGPU.def | 2 + clang/lib/AST/ASTContext.cpp | 4 + clang/lib/CodeGen/CGBuiltin.cpp | 13 +++ .../CodeGenHIP/builtins-make-buffer-rsrc.hip | 105 ++ .../builtins-amdgcn-make-buffer-rsrc.cl | 93 6 files changed, 218 insertions(+) create mode 100644 clang/test/CodeGenHIP/builtins-make-buffer-rsrc.hip create mode 100644 clang/test/CodeGenOpenCL/builtins-amdgcn-make-buffer-rsrc.cl diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def index f356f881d5ef9..d2d500c990b99 100644 --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/include/clang/Basic/Builtins.def @@ -33,6 +33,7 @@ // q -> Scalable vector, followed by the number of elements and the base type. // Q -> target builtin type, followed by a character to distinguish the builtin type //Qa -> AArch64 svcount_t builtin type. +//Qb -> AMDGPU __amdgpu_buffer_rsrc_t builtin type. // E -> ext_vector, followed by the number of elements and the base type. // X -> _Complex, followed by the base type. // Y -> ptrdiff_t diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 9e6800ea814a0..a73e63355cfd7 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -148,6 +148,8 @@ BUILTIN(__builtin_amdgcn_qsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") +BUILTIN(__builtin_amdgcn_make_buffer_rsrc, "Qbv*sii", "nc") + //===--===// // Ballot builtins. //===--===// diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index a4e6d3b108c8a..fa12802c8cc34 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -11546,6 +11546,10 @@ static QualType DecodeTypeFromStr(const char *, const ASTContext , Type = Context.SveCountTy; break; } +case 'b': { + Type = Context.AMDGPUBufferRsrcTy; + break; +} default: llvm_unreachable("Unexpected target builtin type"); } diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 08a89bd123d03..51b182080f0fc 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -615,6 +615,17 @@ static Value *emitTernaryBuiltin(CodeGenFunction , return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 }); } +static Value *emitQuaternaryBuiltin(CodeGenFunction , const CallExpr *E, +unsigned IntrinsicID) { + llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); + llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1)); + llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2)); + llvm::Value *Src3 = CGF.EmitScalarExpr(E->getArg(3)); + + Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType()); + return CGF.Builder.CreateCall(F, {Src0, Src1, Src2, Src3}); +} + // Emit an intrinsic that has 1 float or double operand, and 1 integer. static Value *emitFPIntBuiltin(CodeGenFunction , const CallExpr *E, @@ -19111,6 +19122,8 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, CGM.getIntrinsic(Intrinsic::amdgcn_s_sendmsg_rtn, {ResultType}); return Builder.CreateCall(F, {Arg}); } + case AMDGPU::BI__builtin_amdgcn_make_buffer_rsrc: +return emitQuaternaryBuiltin(*this, E, Intrinsic::amdgcn_make_buffer_rsrc); default: return nullptr; } diff --git a/clang/test/CodeGenHIP/builtins-make-buffer-rsrc.hip b/clang/test/CodeGenHIP/builtins-make-buffer-rsrc.hip new file mode 100644 index 0..c1a30633f3d0a --- /dev/null +++ b/clang/test/CodeGenHIP/builtins-make-buffer-rsrc.hip @@ -0,0 +1,105 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu verde -emit-llvm -disable-llvm-optzns -fcuda-is-device -o - %s | FileCheck %s + +#define __device__ __attribute__((device)) + +// CHECK-LABEL: define dso_local ptr addrspace(8) @_Z31test_amdgcn_make_buffer_rsrc_p0Pvsii( +// CHECK-SAME: ptr noundef [[P:%.*]], i16 noundef signext [[STRIDE:%.*]], i32 noundef [[NUM:%.*]], i32 noundef [[FLAGS:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT:
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian closed https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
shiltian wrote: ping https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/94576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94576 >From 013a40d474e3acaa7a090d5e279f2d8a2f18fbd8 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 18:48:33 -0400 Subject: [PATCH 1/3] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 5 ++ clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip | 20 + clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 12 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 32 files changed, 299 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types
[clang] [HIP][Clang][Sema] Fix crash when calling builtins with pointer arguments (PR #95957)
@@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -fsyntax-only -verify %s + +void call_amdgpu_builtins() { + __builtin_amdgcn_fence(); // expected-error {{too few arguments to function call, expected 2, have 0}} + __builtin_amdgcn_atomic_inc32(); // expected-error {{too few arguments to function call, expected 4, have 0}} + __builtin_amdgcn_atomic_inc32(0); // expected-error {{too few arguments to function call, expected 4, have 1}} + __builtin_amdgcn_atomic_inc32(0, 0); // expected-error {{too few arguments to function call, expected 4, have 2}} + __builtin_amdgcn_atomic_inc32(0, 0, 0); // expected-error {{too few arguments to function call, expected 4, have 3}} + __builtin_amdgcn_atomic_inc64(); // expected-error {{too few arguments to function call, expected 4, have 0}} + __builtin_amdgcn_atomic_dec32(); // expected-error {{too few arguments to function call, expected 4, have 0}} + __builtin_amdgcn_atomic_dec64(); // expected-error {{too few arguments to function call, expected 4, have 0}} + __builtin_amdgcn_div_scale(); // expected-error {{too few arguments to function call, expected 4, have 0}} + __builtin_amdgcn_div_scale(0); // expected-error {{too few arguments to function call, expected 4, have 1}} + __builtin_amdgcn_div_scale(0, 0); // expected-error {{too few arguments to function call, expected 4, have 2}} + __builtin_amdgcn_div_scale(0, 0, 0); // expected-error {{too few arguments to function call, expected 4, have 3}} + __builtin_amdgcn_div_scalef(); // expected-error {{too few arguments to function call, expected 4, have 0}} + __builtin_amdgcn_ds_faddf(); // expected-error {{too few arguments to function call, expected 5, have 0}} + __builtin_amdgcn_ds_fminf(); // expected-error {{too few arguments to function call, expected 5, have 0}} + __builtin_amdgcn_ds_fmaxf(); // expected-error {{too few arguments to function call, expected 5, have 0}} + __builtin_amdgcn_ds_append(); // expected-error {{too few arguments to function call, expected 1, have 0}} + __builtin_amdgcn_ds_consume(); // expected-error {{too few arguments to function call, expected 1, have 0}} + __builtin_amdgcn_is_shared(); // expected-error {{too few arguments to function call, expected 1, have 0}} + __builtin_amdgcn_is_private(); // expected-error {{too few arguments to function call, expected 1, have 0}} +} shiltian wrote: empty line at EOF https://github.com/llvm/llvm-project/pull/95957 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HIP][Clang][Sema] Fix crash when calling builtins with pointer arguments (PR #95957)
@@ -6628,7 +6628,8 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, // the parameter type. if (getLangOpts().HIP && getLangOpts().CUDAIsDevice && FD && FD->getBuiltinID()) { - for (unsigned Idx = 0; Idx < FD->param_size(); ++Idx) { + for (unsigned Idx = 0; Idx < ArgExprs.size() && Idx < FD->param_size(); shiltian wrote: We might want to bail out early if the size doesn't match. https://github.com/llvm/llvm-project/pull/95957 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
@@ -33,6 +33,7 @@ // q -> Scalable vector, followed by the number of elements and the base type. // Q -> target builtin type, followed by a character to distinguish the builtin type //Qa -> AArch64 svcount_t builtin type. +//Qb -> AMDGPU __amdgpu_buffer_rsrc_t builtin type. shiltian wrote: It indeed sounds like that, but I checked where `Qa` was introduced. It was after the type was introduced. https://reviews.llvm.org/D150953 https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/95276 >From 013a40d474e3acaa7a090d5e279f2d8a2f18fbd8 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 18:48:33 -0400 Subject: [PATCH 1/2] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 5 ++ clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip | 20 + clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 12 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 32 files changed, 299 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
@@ -33,6 +33,7 @@ // q -> Scalable vector, followed by the number of elements and the base type. // Q -> target builtin type, followed by a character to distinguish the builtin type //Qa -> AArch64 svcount_t builtin type. +//Qb -> AMDGPU __amdgpu_buffer_rsrc_t builtin type. shiltian wrote: Well not really. We can't test it out in the parent patch w/o introduction of a builtin function. https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/95276 >From 013a40d474e3acaa7a090d5e279f2d8a2f18fbd8 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 18:48:33 -0400 Subject: [PATCH 1/2] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 5 ++ clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip | 20 + clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 12 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 32 files changed, 299 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
@@ -0,0 +1,95 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu verde -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu tonga -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +// CHECK-LABEL: @test_amdgcn_make_buffer_rsrc_p0( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr [[P:%.*]], i16 [[STRIDE:%.*]], i32 [[NUM:%.*]], i32 [[FLAGS:%.*]]) +// CHECK-NEXT:ret ptr addrspace(8) [[TMP0]] +// +__buffer_rsrc_t test_amdgcn_make_buffer_rsrc_p0(void *p, short stride, int num, int flags) { + return __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); shiltian wrote: This test has been taken care in https://github.com/llvm/llvm-project/pull/94830. https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/95276 >From 013a40d474e3acaa7a090d5e279f2d8a2f18fbd8 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 18:48:33 -0400 Subject: [PATCH 1/2] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 5 ++ clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip | 20 + clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 12 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 32 files changed, 299 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 013a40d474e3acaa7a090d5e279f2d8a2f18fbd8 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 18:48:33 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 5 ++ clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip | 20 + clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 12 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 32 files changed, 299 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
shiltian wrote: @yxsamliu https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 913d0761133b5f6f7785e04b23d0a8744e140842 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 15:29:47 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 5 ++ clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip | 19 + clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 12 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 32 files changed, 298 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From bc137f40cd524c47094ce39ec4e4d567283fc2da Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 15:19:39 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 5 ++ clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip | 19 + clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 11 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 32 files changed, 297 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,17 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 -triple amdgcn -Wno-unused-value %s + shiltian wrote: TBH I don't think there is any difference but I added them anyway. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 15347886bf3327d1a23a2caa65f58cba7ef86fe5 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 14:27:09 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 + clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip | 19 + clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 11 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 32 files changed, 296 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaHIP/amdgpu-buffer-rsrc.hip create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 1751b9ed484e88213ba56be9961769bcabf085be Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 17 Jun 2024 14:23:00 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 + clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 82 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl | 11 +++ clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 31 files changed, 277 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp create mode 100644 clang/test/SemaOpenCL/amdgpu-buffer-rsrc.cl create mode 100644 clang/test/SemaOpenMP/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 15ed0af5f5d23213fd4c10ff704ac26bb1b80030 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Sun, 16 Jun 2024 23:07:29 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 + clang/lib/Sema/Sema.cpp | 8 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 84 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 29 files changed, 252 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file defines various AMDGPU
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 7b31bbbd9efd13ea78d1a7bfef00cbd943e27876 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Fri, 14 Jun 2024 13:22:17 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 + clang/lib/Sema/Sema.cpp | 7 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 84 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 29 files changed, 251 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..e0d7be470a325 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file defines various AMDGPU
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file defines various AMDGPU builtin types. +// +//===--===// + +#ifndef AMDGPU_OPAQUE_PTR_TYPE +#define AMDGPU_OPAQUE_PTR_TYPE(Name, MangledName, AS, Width, Align, Id, SingletonId) \ + AMDGPU_TYPE(Name, Id, SingletonId) +#endif + +AMDGPU_OPAQUE_PTR_TYPE("__amdgcn_buffer_rsrc_t", "__amdgcn_buffer_rsrc_t", 8, 128, 128, AMDGPUBufferRsrc, AMDGPUBufferRsrcTy) shiltian wrote: What is our standard here? Our builtin, intrinsics, and target triple are using `amdgcn`. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,84 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature + // REQUIRES: amdgpu-registered-target + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +typedef struct AA_ty { + int x; + __amdgcn_buffer_rsrc_t r; +} AA; + +AA getAA(void *p); +__amdgcn_buffer_rsrc_t getBufferImpl(void *p); +void consumeBuffer(__amdgcn_buffer_rsrc_t); + +// CHECK-LABEL: define {{[^@]+}}@getBuffer shiltian wrote: As I mentioned in the previous outdated comment, `update_cc_test_checks.py` doesn't check return type even with `--function-signature`. However, the `ret` instruction at the end of the function can be used to verify the return type. In this case, it has `ret ptr addrspace(8) [[CALL]]` so the return type is `ptr addrspace(8)`. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From baa19285069854598437694cb2094283598cf8c2 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Fri, 14 Jun 2024 12:58:08 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 + clang/lib/Sema/Sema.cpp | 7 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 84 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 29 files changed, 251 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..c035c6dbced11 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file defines various AMDGPU
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,69 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + // REQUIRES: amdgpu-registered-target + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -emit-llvm -o - %s | FileCheck %s + // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +typedef struct AA_ty { + int x; + __amdgcn_buffer_rsrc_t r; +} AA; + +AA getAA(void *p); +__amdgcn_buffer_rsrc_t getBuffer(void *p); +void consumeBuffer(__amdgcn_buffer_rsrc_t); + +// CHECK-LABEL: @consumeBufferPtr( shiltian wrote: `update_cc_test_checks.py` doesn't appear to have an argument to check the function return type. I added `--function-signature` though. The `ret` instruction at the end of each function can be used to verify the return type. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 24703e0480835fb2c491b7140c2ab5022218777d Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Thu, 13 Jun 2024 18:43:29 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 + clang/include/clang/Basic/AMDGPUTypes.def | 21 + .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 clang/lib/AST/ASTImporter.cpp | 4 + clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 + clang/lib/Sema/Sema.cpp | 7 ++ clang/lib/Sema/SemaExpr.cpp | 4 + clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 84 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 clang/tools/libclang/CIndex.cpp | 2 + 29 files changed, 251 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..c035c6dbced11 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file defines various AMDGPU
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 2eb6b3a58692ae3b8a6250e87516450a5085fa0f Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Thu, 13 Jun 2024 17:02:11 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 ++ clang/include/clang/Basic/AMDGPUTypes.def | 21 ++ .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 + clang/lib/AST/ASTImporter.cpp | 4 ++ clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 ++ clang/lib/Sema/Sema.cpp | 7 ++ clang/lib/Sema/SemaExpr.cpp | 4 ++ clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 69 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 + clang/tools/libclang/CIndex.cpp | 2 + 29 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..c035c6dbced11 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file defines various
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -x hip -aux-triple amdgcn-amd-amdhsa %s -fsyntax-only -verify + +#define __device__ __attribute__((device)) + +__device__ __amdgcn_buffer_rsrc_t test_buffer_rsrc_t_device() {} // expected-warning {{non-void function does not return a value}} +__amdgcn_buffer_rsrc_t test_buffer_rsrc_t_host() {} // expected-error {{'__amdgcn_buffer_rsrc_t' can only be used in device-side function}} shiltian wrote: Okay, that makes sense. Then I'll remove this test. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -x hip -aux-triple amdgcn-amd-amdhsa %s -fsyntax-only -verify + +#define __device__ __attribute__((device)) + +__device__ __amdgcn_buffer_rsrc_t test_buffer_rsrc_t_device() {} // expected-warning {{non-void function does not return a value}} +__amdgcn_buffer_rsrc_t test_buffer_rsrc_t_host() {} // expected-error {{'__amdgcn_buffer_rsrc_t' can only be used in device-side function}} shiltian wrote: The only thing left is this part. Is it possible to force it to only be used in device-side function? @yxsamliu https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,9 @@ + +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s + +// CHECK: name: "__amdgcn_buffer_rsrc_t",{{.*}}baseType: ![[BT:[0-9]+]] +// CHECK: [[BT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "__amdgcn_buffer_rsrc_t", {{.*}} flags: DIFlagFwdDecl) shiltian wrote: For the debug type, I made it a struct type, because I don't think we expose it as a pointer even though it is used internally as one. It is not an integer as well. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
shiltian wrote: Now `__amdgcn_buffer_rsrc_t` is a 128-bit wide builtin opaque type. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From bbe2a055c2448d8caf020d33c7e96a3e3bd75165 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Thu, 13 Jun 2024 15:39:02 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/Type.h| 3 + clang/include/clang/AST/TypeProperties.td | 4 ++ clang/include/clang/Basic/AMDGPUTypes.def | 21 ++ .../include/clang/Serialization/ASTBitCodes.h | 5 +- clang/lib/AST/ASTContext.cpp | 16 + clang/lib/AST/ASTImporter.cpp | 4 ++ clang/lib/AST/ExprConstant.cpp| 2 + clang/lib/AST/ItaniumMangle.cpp | 6 ++ clang/lib/AST/MicrosoftMangle.cpp | 2 + clang/lib/AST/NSAPI.cpp | 2 + clang/lib/AST/PrintfFormatString.cpp | 2 + clang/lib/AST/Type.cpp| 6 ++ clang/lib/AST/TypeLoc.cpp | 2 + clang/lib/CodeGen/CGDebugInfo.cpp | 11 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 + clang/lib/CodeGen/CodeGenTypes.cpp| 5 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 + clang/lib/Index/USRGeneration.cpp | 4 ++ clang/lib/Sema/Sema.cpp | 7 ++ clang/lib/Sema/SemaExpr.cpp | 4 ++ clang/lib/Serialization/ASTCommon.cpp | 5 ++ clang/lib/Serialization/ASTReader.cpp | 5 ++ clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 69 +++ clang/test/SemaCUDA/amdgpu-buffer-rsrc-ty.cu | 6 ++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 17 + clang/tools/libclang/CIndex.cpp | 2 + 30 files changed, 242 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCUDA/amdgpu-buffer-rsrc-ty.cu create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 53ece996769a8..4d1f440506e09 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fab233b62d8d1..61246479188e9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..c035c6dbced11 --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
@@ -0,0 +1,95 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu verde -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu tonga -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +// CHECK-LABEL: @test_amdgcn_make_buffer_rsrc_p0( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr [[P:%.*]], i16 [[STRIDE:%.*]], i32 [[NUM:%.*]], i32 [[FLAGS:%.*]]) +// CHECK-NEXT:ret ptr addrspace(8) [[TMP0]] +// +__buffer_rsrc_t test_amdgcn_make_buffer_rsrc_p0(void *p, short stride, int num, int flags) { + return __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); shiltian wrote: For example, we have the following code: ``` void test_amdgcn_buffer_rsrc_t_assignment(void *p, short stride, int num, int flags, char c) { __buffer_rsrc_t rsrc = __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); bar(); __builtin_amdgcn_raw_ptr_buffer_store_i8(c, rsrc, 0, 0, 0); } ``` The generated IR would be: ``` define dso_local void @test_amdgcn_buffer_rsrc_t_assignment(ptr nocapture noundef writeonly %p, i16 noundef signext %stride, i32 noundef %num, i32 noundef %flags, i8 noundef signext %c) local_unnamed_addr { entry: %0 = tail call ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr %p, i16 %stride, i32 %num, i32 %flags) tail call void @bar() tail call void @llvm.amdgcn.raw.ptr.buffer.store.i8(i8 %c, ptr addrspace(8) %0, i32 0, i32 0, i32 0) ret void } declare ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr readnone, i16, i32, i32) #1 declare void @bar() local_unnamed_addr #2 ``` However, I just checked the potential use case of this, such as https://github.com/ROCm/composable_kernel/blob/acda4c5a3c34c13b71475fdd963e61182bba8a76/include/ck_tile/core/arch/amd_buffer_addressing.hpp#L71, we will need this type to be able to be passed around, so a sizeless type doesn't work. To move forward, I think we still need to make it a 128-bit fat pointer. I'm not sure yet if we want to make it an `i128` or `4xi32`, or a struct type because we definitely need to prevent the case like `__buffer_rsrc_t rsrc = some_i128_val;` or `__buffer_rsrc_t rsrc = some_4xi32_val;`. At clang codegen level, it is still taken as AS8 pointer. WDYT? @yxsamliu @arsenm @krzysz00 https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
shiltian wrote: > I am wondering whether prefix the builtin type with `__amdgcn_` would be > better since I envision risk of conflicting with reserved names of other > compilers or standard libraries. In the patch where the type was introduced we had a brief back-and-forth. I checked the reference type WASM introduced and they don't have prefix. I don't think in the future we'd have a cross-platform/-compiler type called `__buffer_rsrc_t`, and it happens, it is not supposed to have `__` prefix. However, I'm by no means a language expert, so I'm fine if we really want to add that. https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
@@ -0,0 +1,95 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu verde -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu tonga -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +// CHECK-LABEL: @test_amdgcn_make_buffer_rsrc_p0( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr [[P:%.*]], i16 [[STRIDE:%.*]], i32 [[NUM:%.*]], i32 [[FLAGS:%.*]]) +// CHECK-NEXT:ret ptr addrspace(8) [[TMP0]] +// +__buffer_rsrc_t test_amdgcn_make_buffer_rsrc_p0(void *p, short stride, int num, int flags) { + return __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); shiltian wrote: No, we don't allow to have that. Per the discussion with @arsenm , `__buffer_rsrc_t` is a sizeless target opaque type. It can't be used in anywhere that requires its size to be known. https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -x hip -aux-triple amdgcn-amd-amdhsa %s -fsyntax-only -verify + +#define __device__ __attribute__((device)) + +__device__ __buffer_rsrc_t test_buffer_rsrc_t_device() {} // expected-warning {{non-void function does not return a value}} +__buffer_rsrc_t test_buffer_rsrc_t_host() {} // expected-error {{'__buffer_rsrc_t' can only be used in device-side function}} shiltian wrote: @yxsamliu I forced that the type is only available if the target triple or the aux target triple is amdgpu. However, that doesn't force the check that `__buffer_rsrc_t` can only be used in device-side function. How do we do this kind of type check in Sema? https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From cbb274f279c918bd0aaa601f87e50a2d10b71c25 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Wed, 12 Jun 2024 15:46:55 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 12 + clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 9 +++ clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 10 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 7 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCUDA/amdgpu-buffer-rsrc-ty.cu | 6 + clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 16 clang/tools/libclang/CIndex.cpp | 2 ++ 30 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCUDA/amdgpu-buffer-rsrc-ty.cu create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 8bce4812f0d48..0ebe04e0886d7 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/95276 >From 1b06131a10e1f8067961624b02bba3354d5057c0 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Wed, 12 Jun 2024 09:18:49 -0400 Subject: [PATCH 1/2] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 11 clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 9 +++ clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 10 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 6 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 16 clang/tools/libclang/CIndex.cpp | 2 ++ 29 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index a1d1d1c51cd41..2328141b27e79 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +//
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] buffer rsrc builtin (PR #95276)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] buffer rsrc builtin (PR #95276)
https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/95276 - **[Clang][AMDGPU] Add a new builtin type for buffer rsrc** - **[Clang][AMDGPU] Add a builtin for `llvm.amdgcn.make.buffer.rsrc` intrinsic** >From 1b06131a10e1f8067961624b02bba3354d5057c0 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Wed, 12 Jun 2024 09:18:49 -0400 Subject: [PATCH 1/2] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 11 clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 9 +++ clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 10 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 6 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 16 clang/tools/libclang/CIndex.cpp | 2 ++ 29 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index a1d1d1c51cd41..2328141b27e79 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 1b06131a10e1f8067961624b02bba3354d5057c0 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Wed, 12 Jun 2024 09:18:49 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 11 clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 9 +++ clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 10 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 6 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 16 clang/tools/libclang/CIndex.cpp | 2 ++ 29 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index a1d1d1c51cd41..2328141b27e79 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +//
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
shiltian wrote: > how does a user initialize/populate this type of objects? by calling a > builtin function? yes. The builtin functions will come next. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
shiltian wrote: any comment/concern? https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 731c2adb3bf69bd1f337691eeb34756e521d47f3 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 10 Jun 2024 15:40:41 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 11 clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 9 +++ clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 10 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 6 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 16 clang/tools/libclang/CIndex.cpp | 2 ++ 29 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 8bce4812f0d48..0ebe04e0886d7 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +//
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -2201,6 +2207,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = 8; \ break; #include "clang/Basic/WebAssemblyReferenceTypes.def" +case BuiltinType::AMDGPUBufferRsrc: + Width = 0; + Align = 256; shiltian wrote: Based on our data layout, it looks like AS8 pointer is 128 bit and AS7 is 160 bit. The alignment here should be 128. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From 57e60fb4d4d37f19ddfbc4a0878b7ee2e180aa2d Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 10 Jun 2024 15:23:07 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 11 clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 9 +++ clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 10 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 6 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-type-debug-info.c | 9 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 16 clang/tools/libclang/CIndex.cpp | 2 ++ 29 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type-debug-info.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 8bce4812f0d48..0ebe04e0886d7 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +//
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -2201,6 +2207,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = 8; \ break; #include "clang/Basic/WebAssemblyReferenceTypes.def" +case BuiltinType::AMDGPUBufferRsrc: + Width = 0; + Align = 256; shiltian wrote: This has to be power of 2 so 160 -> 256. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94830 >From b468736cad511e36c7ac22d2ad86ba01ca21d8a5 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Mon, 10 Jun 2024 11:37:17 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 11 clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 6 + clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 10 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 6 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 10 +++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 9 +++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 11 clang/tools/libclang/CIndex.cpp | 2 ++ 28 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 8bce4812f0d48..0ebe04e0886d7 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file defines various AMDGPU builtin types. +//
[clang] [test][OpenMP] Avoid writing to a potentially write-protected dir (PR #94931)
https://github.com/shiltian approved this pull request. https://github.com/llvm/llvm-project/pull/94931 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,9 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -fclang-abi-compat=latest -triple amdgcn %s -emit-llvm -o - | FileCheck %s shiltian wrote: Copy/paste from other tests Lol https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file defines various AMDGPU builtin types. +// +//===--===// + +#ifndef AMDGPU_OPAQUE_TYPE +#define AMDGPU_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \ + AMDGPU_TYPE(Name, Id, SingletonId) +#endif + +AMDGPU_OPAQUE_TYPE("__buffer_rsrc_t", "__buffer_rsrc_t", AMDGPUBufferRsrc, AMDGPUBufferRsrcTy) shiltian wrote: Probably not. I checked WASM reference types and they don't have wasm prefix. https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
@@ -2200,6 +2206,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = 8; \ break; #include "clang/Basic/WebAssemblyReferenceTypes.def" +case BuiltinType::AMDGPUBufferRsrc: + Width = 128; + Align = 128; shiltian wrote: Do we want to expose it as a pointer, a sizeless object, or a vector of 160 bits? https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
shiltian wrote: https://github.com/llvm/llvm-project/pull/94830 for buffer rsrc data type. Will update this patch afterwards. https://github.com/llvm/llvm-project/pull/94576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/94830 None >From 891c37a3f6002c40aa0ded803330f61c3d16e6bb Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Fri, 7 Jun 2024 22:37:13 -0400 Subject: [PATCH] [Clang][AMDGPU] Add a new builtin type for buffer rsrc --- clang/include/clang/AST/ASTContext.h | 2 ++ clang/include/clang/AST/Type.h| 3 +++ clang/include/clang/AST/TypeProperties.td | 4 +++ clang/include/clang/Basic/AMDGPUTypes.def | 21 +++ clang/include/clang/Basic/Builtins.def| 1 + .../include/clang/Serialization/ASTBitCodes.h | 5 +++- clang/lib/AST/ASTContext.cpp | 15 +++ clang/lib/AST/ASTImporter.cpp | 4 +++ clang/lib/AST/ExprConstant.cpp| 2 ++ clang/lib/AST/ItaniumMangle.cpp | 6 + clang/lib/AST/MicrosoftMangle.cpp | 2 ++ clang/lib/AST/NSAPI.cpp | 2 ++ clang/lib/AST/PrintfFormatString.cpp | 2 ++ clang/lib/AST/Type.cpp| 6 + clang/lib/AST/TypeLoc.cpp | 2 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 3 ++- clang/lib/CodeGen/CGDebugInfo.h | 2 ++ clang/lib/CodeGen/CodeGenTypes.cpp| 2 ++ clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 ++ clang/lib/Index/USRGeneration.cpp | 4 +++ clang/lib/Sema/Sema.cpp | 6 + clang/lib/Sema/SemaExpr.cpp | 4 +++ clang/lib/Serialization/ASTCommon.cpp | 5 clang/lib/Serialization/ASTReader.cpp | 5 clang/test/AST/ast-dump-amdgpu-types.c| 9 +++ clang/test/CodeGen/amdgpu-buffer-rsrc-type.c | 8 ++ .../amdgpu-buffer-rsrc-typeinfo.cpp | 8 ++ .../CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl | 26 +++ clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp | 11 clang/tools/libclang/CIndex.cpp | 2 ++ 30 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 clang/include/clang/Basic/AMDGPUTypes.def create mode 100644 clang/test/AST/ast-dump-amdgpu-types.c create mode 100644 clang/test/CodeGen/amdgpu-buffer-rsrc-type.c create mode 100644 clang/test/CodeGenCXX/amdgpu-buffer-rsrc-typeinfo.cpp create mode 100644 clang/test/CodeGenOpenCL/amdgcn-buffer-rsrc-type.cl create mode 100644 clang/test/SemaCXX/amdgpu-buffer-rsrc.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index a1d1d1c51cd41..2328141b27e79 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1147,6 +1147,8 @@ class ASTContext : public RefCountedBase { #include "clang/Basic/RISCVVTypes.def" #define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(Name, Id, SingletonId) CanQualType SingletonId; +#include "clang/Basic/AMDGPUTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..cbcd6d0f97efe 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3015,6 +3015,9 @@ class BuiltinType : public Type { // WebAssembly reference types #define WASM_TYPE(Name, Id, SingletonId) Id, #include "clang/Basic/WebAssemblyReferenceTypes.def" +// AMDGPU types +#define AMDGPU_TYPE(Name, Id, SingletonId) Id, +#include "clang/Basic/AMDGPUTypes.def" // All other builtin types #define BUILTIN_TYPE(Id, SingletonId) Id, #define LAST_BUILTIN_TYPE(Id) LastKind = Id diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 40dd16f080e2e..aba14b222a03a 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -861,6 +861,10 @@ let Class = BuiltinType in { case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/Basic/WebAssemblyReferenceTypes.def" +#define AMDGPU_TYPE(NAME, ID, SINGLETON_ID) \ + case BuiltinType::ID: return ctx.SINGLETON_ID; +#include "clang/Basic/AMDGPUTypes.def" + #define BUILTIN_TYPE(ID, SINGLETON_ID) \ case BuiltinType::ID: return ctx.SINGLETON_ID; #include "clang/AST/BuiltinTypes.def" diff --git a/clang/include/clang/Basic/AMDGPUTypes.def b/clang/include/clang/Basic/AMDGPUTypes.def new file mode 100644 index 0..226e75480037c --- /dev/null +++ b/clang/include/clang/Basic/AMDGPUTypes.def @@ -0,0 +1,21 @@ +//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +//
[clang] [flang] [libclc] [llvm] [AMDGPU] Add a new target gfx1152 (PR #94534)
shiltian wrote: @jayfoad @kzhuravl fixed in https://github.com/llvm/llvm-project/commit/7eab68026d931860e9c750e8b8b29a2076370d38 https://github.com/llvm/llvm-project/pull/94534 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [libclc] [llvm] [AMDGPU] Add a new target gfx1152 (PR #94534)
https://github.com/shiltian closed https://github.com/llvm/llvm-project/pull/94534 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94576 >From d520ea7bdc3abe864e1fc76a501189eb094e845d Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Thu, 6 Jun 2024 09:49:32 -0400 Subject: [PATCH] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` --- clang/include/clang/Basic/BuiltinsAMDGPU.def | 14 + clang/lib/CodeGen/CGBuiltin.cpp | 23 ++ .../builtins-amdgcn-raw-ptr-buffer-store.cl | 264 ++ ...ltins-amdgcn-raw-ptr-buffer-store-error.cl | 67 + 4 files changed, 368 insertions(+) create mode 100644 clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl create mode 100644 clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-store-error.cl diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 9e6800ea814a0..17764a0b7fbda 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -148,6 +148,20 @@ BUILTIN(__builtin_amdgcn_qsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i8, "vcv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i16, "vsv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i32, "viv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_f16, "vhv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_f32, "vfv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2i16, "vV2sv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2i32, "vV2iv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2f16, "vV2hv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2f32, "vV2fv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4i16, "vV4sv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4i32, "vV4iv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4f16, "vV4hv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4f32, "vV4fv*8iiIi", "n") + //===--===// // Ballot builtins. //===--===// diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 37d0c478e0330..f6031f7ddc005 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -19063,6 +19063,29 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, CGM.getIntrinsic(Intrinsic::amdgcn_s_sendmsg_rtn, {ResultType}); return Builder.CreateCall(F, {Arg}); } + + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_i8: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_i16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_i32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_f32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_f16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2i16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2i32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2f16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2f32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4i16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4i32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4f16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4f32: { +llvm::Value *VData = EmitScalarExpr(E->getArg(0)); +llvm::Value *Rsrc = EmitScalarExpr(E->getArg(1)); +llvm::Value *Offset = EmitScalarExpr(E->getArg(2)); +llvm::Value *SOffset = EmitScalarExpr(E->getArg(3)); +llvm::Value *Aux = EmitScalarExpr(E->getArg(4)); +Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_raw_ptr_buffer_store, + VData->getType()); +return Builder.CreateCall(F, {VData, Rsrc, Offset, SOffset, Aux}); + } default: return nullptr; } diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl new file mode 100644 index 0..4ac13f00407ff --- /dev/null +++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl @@ -0,0 +1,264 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -emit-llvm -o - %s | FileCheck %s --check-prefixes=VERDE +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -emit-llvm -o - %s | FileCheck %s --check-prefixes=GFX8 +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s --check-prefixes=GFX11 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +typedef short v2i16
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94576 >From 6f7374e4085954ad1ed1d66be154bd14dba658f9 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Thu, 6 Jun 2024 09:49:05 -0400 Subject: [PATCH] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` --- clang/include/clang/Basic/BuiltinsAMDGPU.def | 14 + clang/lib/CodeGen/CGBuiltin.cpp | 23 ++ .../builtins-amdgcn-raw-ptr-buffer-store.cl | 264 ++ ...ltins-amdgcn-raw-ptr-buffer-store-error.cl | 68 + 4 files changed, 369 insertions(+) create mode 100644 clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl create mode 100644 clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-store-error.cl diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 9e6800ea814a0..17764a0b7fbda 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -148,6 +148,20 @@ BUILTIN(__builtin_amdgcn_qsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i8, "vcv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i16, "vsv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i32, "viv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_f16, "vhv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_f32, "vfv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2i16, "vV2sv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2i32, "vV2iv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2f16, "vV2hv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2f32, "vV2fv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4i16, "vV4sv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4i32, "vV4iv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4f16, "vV4hv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4f32, "vV4fv*8iiIi", "n") + //===--===// // Ballot builtins. //===--===// diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 37d0c478e0330..f6031f7ddc005 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -19063,6 +19063,29 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, CGM.getIntrinsic(Intrinsic::amdgcn_s_sendmsg_rtn, {ResultType}); return Builder.CreateCall(F, {Arg}); } + + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_i8: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_i16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_i32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_f32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_f16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2i16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2i32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2f16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2f32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4i16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4i32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4f16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4f32: { +llvm::Value *VData = EmitScalarExpr(E->getArg(0)); +llvm::Value *Rsrc = EmitScalarExpr(E->getArg(1)); +llvm::Value *Offset = EmitScalarExpr(E->getArg(2)); +llvm::Value *SOffset = EmitScalarExpr(E->getArg(3)); +llvm::Value *Aux = EmitScalarExpr(E->getArg(4)); +Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_raw_ptr_buffer_store, + VData->getType()); +return Builder.CreateCall(F, {VData, Rsrc, Offset, SOffset, Aux}); + } default: return nullptr; } diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl new file mode 100644 index 0..4ac13f00407ff --- /dev/null +++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl @@ -0,0 +1,264 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -emit-llvm -o - %s | FileCheck %s --check-prefixes=VERDE +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -emit-llvm -o - %s | FileCheck %s --check-prefixes=GFX8 +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s --check-prefixes=GFX11 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +typedef short v2i16
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94576 >From 13b2f0446b89c866214b446b1c1653c10a89efcc Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Thu, 6 Jun 2024 09:47:40 -0400 Subject: [PATCH] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` --- clang/include/clang/Basic/BuiltinsAMDGPU.def | 14 + clang/lib/CodeGen/CGBuiltin.cpp | 23 ++ .../builtins-amdgcn-raw-ptr-buffer-store.cl | 264 ++ ...ltins-amdgcn-raw-ptr-buffer-store-error.cl | 70 + 4 files changed, 371 insertions(+) create mode 100644 clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl create mode 100644 clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-store-error.cl diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 9e6800ea814a0..17764a0b7fbda 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -148,6 +148,20 @@ BUILTIN(__builtin_amdgcn_qsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i8, "vcv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i16, "vsv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_i32, "viv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_f16, "vhv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_f32, "vfv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2i16, "vV2sv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2i32, "vV2iv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2f16, "vV2hv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v2f32, "vV2fv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4i16, "vV4sv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4i32, "vV4iv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4f16, "vV4hv*8iiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_store_v4f32, "vV4fv*8iiIi", "n") + //===--===// // Ballot builtins. //===--===// diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 37d0c478e0330..f6031f7ddc005 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -19063,6 +19063,29 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, CGM.getIntrinsic(Intrinsic::amdgcn_s_sendmsg_rtn, {ResultType}); return Builder.CreateCall(F, {Arg}); } + + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_i8: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_i16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_i32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_f32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_f16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2i16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2i32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2f16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v2f32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4i16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4i32: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4f16: + case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_store_v4f32: { +llvm::Value *VData = EmitScalarExpr(E->getArg(0)); +llvm::Value *Rsrc = EmitScalarExpr(E->getArg(1)); +llvm::Value *Offset = EmitScalarExpr(E->getArg(2)); +llvm::Value *SOffset = EmitScalarExpr(E->getArg(3)); +llvm::Value *Aux = EmitScalarExpr(E->getArg(4)); +Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_raw_ptr_buffer_store, + VData->getType()); +return Builder.CreateCall(F, {VData, Rsrc, Offset, SOffset, Aux}); + } default: return nullptr; } diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl new file mode 100644 index 0..4ac13f00407ff --- /dev/null +++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-ptr-buffer-store.cl @@ -0,0 +1,264 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -emit-llvm -o - %s | FileCheck %s --check-prefixes=VERDE +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -emit-llvm -o - %s | FileCheck %s --check-prefixes=GFX8 +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s --check-prefixes=GFX11 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +typedef short v2i16
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
@@ -0,0 +1,264 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -emit-llvm -o - %s | FileCheck %s --check-prefixes=VERDE +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -emit-llvm -o - %s | FileCheck %s --check-prefixes=GFX8 +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s --check-prefixes=GFX11 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +typedef short v2i16 __attribute__((ext_vector_type(2))); +typedef int v2i32 __attribute__((ext_vector_type(2))); +typedef half v2f16 __attribute__((ext_vector_type(2))); +typedef float v2f32 __attribute__((ext_vector_type(2))); +typedef short v4i16 __attribute__((ext_vector_type(4))); +typedef int v4i32 __attribute__((ext_vector_type(4))); +typedef half v4f16 __attribute__((ext_vector_type(4))); +typedef float v4f32 __attribute__((ext_vector_type(4))); + +// VERDE-LABEL: @test_amdgcn_raw_buffer_store_i8( +// VERDE-NEXT: entry: +// VERDE-NEXT:tail call void @llvm.amdgcn.raw.buffer.store.i8(i8 [[VDATA:%.*]], <4 x i32> [[RSRC:%.*]], i32 0, i32 0, i32 0) +// VERDE-NEXT:ret void +// +// GFX8-LABEL: @test_amdgcn_raw_buffer_store_i8( +// GFX8-NEXT: entry: +// GFX8-NEXT:tail call void @llvm.amdgcn.raw.buffer.store.i8(i8 [[VDATA:%.*]], <4 x i32> [[RSRC:%.*]], i32 0, i32 0, i32 0) +// GFX8-NEXT:ret void +// +// GFX11-LABEL: @test_amdgcn_raw_buffer_store_i8( +// GFX11-NEXT: entry: +// GFX11-NEXT:tail call void @llvm.amdgcn.raw.buffer.store.i8(i8 [[VDATA:%.*]], <4 x i32> [[RSRC:%.*]], i32 0, i32 0, i32 0) +// GFX11-NEXT:ret void +// +void test_amdgcn_raw_buffer_store_i8(char vdata, v4i32 rsrc) { shiltian wrote: Okay, I'll make the change. In `llvm/include/llvm/IR/IntrinsicsAMDGPU.td:1246` where `AMDGPURawPtrBufferStore` is defined, it only says argument 4 is imm, but the comment says argument 2, 3, 4 are all imm. Which one is right? https://github.com/llvm/llvm-project/pull/94576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` (PR #94576)
https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/94576 None >From c874a4d69d472a83dfcd11e8c07518e4d216b725 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Thu, 6 Jun 2024 01:46:17 -0400 Subject: [PATCH] [Clang][AMDGPU] Add builtins for instrinsic `llvm.amdgcn.raw.buffer.store` --- clang/include/clang/Basic/BuiltinsAMDGPU.def | 14 + clang/lib/CodeGen/CGBuiltin.cpp | 23 ++ .../builtins-amdgcn-raw-buffer-store.cl | 264 ++ .../builtins-amdgcn-raw-buffer-store-error.cl | 94 +++ 4 files changed, 395 insertions(+) create mode 100644 clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-store.cl create mode 100644 clang/test/SemaOpenCL/builtins-amdgcn-raw-buffer-store-error.cl diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 433c7795325f0..d6866304f8b1b 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -148,6 +148,20 @@ BUILTIN(__builtin_amdgcn_qsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "WUiWUiUiWUi", "nc") BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc") +BUILTIN(__builtin_amdgcn_raw_buffer_store_i8, "vcV4iIiIiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_i16, "vsV4iIiIiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_i32, "viV4iIiIiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_f16, "vhV4iIiIiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_f32, "vfV4iIiIiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_v2i16, "vV2sV4iIiIiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_v2i32, "vV2iV4iIiIiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_v2f16, "vV2hV4iIiIiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_v2f32, "vV2fV4iIiIiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_v4i16, "vV4sV4iIiIiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_v4i32, "vV4iV4iIiIiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_v4f16, "vV4hV4iIiIiIi", "n") +BUILTIN(__builtin_amdgcn_raw_buffer_store_v4f32, "vV4fV4iIiIiIi", "n") + //===--===// // Ballot builtins. //===--===// diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 37d0c478e0330..706141cbc85ce 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -19063,6 +19063,29 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, CGM.getIntrinsic(Intrinsic::amdgcn_s_sendmsg_rtn, {ResultType}); return Builder.CreateCall(F, {Arg}); } + + case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_i8: + case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_i16: + case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_i32: + case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_f32: + case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_f16: + case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_v2i16: + case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_v2i32: + case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_v2f16: + case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_v2f32: + case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_v4i16: + case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_v4i32: + case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_v4f16: + case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_v4f32: { +llvm::Value *VData = EmitScalarExpr(E->getArg(0)); +llvm::Value *Rsrc = EmitScalarExpr(E->getArg(1)); +llvm::Value *Offset = EmitScalarExpr(E->getArg(2)); +llvm::Value *SOffset = EmitScalarExpr(E->getArg(3)); +llvm::Value *Aux = EmitScalarExpr(E->getArg(4)); +Function *F = +CGM.getIntrinsic(Intrinsic::amdgcn_raw_buffer_store, VData->getType()); +return Builder.CreateCall(F, {VData, Rsrc, Offset, SOffset, Aux}); + } default: return nullptr; } diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-store.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-store.cl new file mode 100644 index 0..0553c53ab41ad --- /dev/null +++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-store.cl @@ -0,0 +1,264 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -emit-llvm -o - %s | FileCheck %s --check-prefixes=VERDE +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -emit-llvm -o - %s | FileCheck %s --check-prefixes=GFX8 +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s --check-prefixes=GFX11 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +typedef short v2i16 __attribute__((ext_vector_type(2))); +typedef int v2i32 __attribute__((ext_vector_type(2))); +typedef half v2f16
[clang] [libclc] [llvm] [AMDGPU] Add a new target gfx1152 (PR #94534)
@@ -1534,6 +1534,12 @@ def FeatureISAVersion11_5_1 : FeatureSet< FeatureVGPRSingleUseHintInsts, Feature1_5xVGPRs])>; +def FeatureISAVersion11_5_2 : FeatureSet< shiltian wrote: GFX1152 is same as GFX1150. In my internal PR, I took @jayfoad 's suggestion of adding a new target ISA version even though they are identical. https://github.com/llvm/llvm-project/pull/94534 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclc] [llvm] [AMDGPU] Add a new target gfx1152 (PR #94534)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/94534 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclc] [llvm] [AMDGPU] Add a new target gfx1152 (PR #94534)
@@ -1534,6 +1534,12 @@ def FeatureISAVersion11_5_1 : FeatureSet< FeatureVGPRSingleUseHintInsts, Feature1_5xVGPRs])>; +def FeatureISAVersion11_5_2 : FeatureSet< shiltian wrote: Are they not? https://github.com/llvm/llvm-project/pull/94534 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclc] [llvm] [AMDGPU] Add a new target gfx1152 (PR #94534)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94534 >From 1bdb851ff0b21e73228a2f0a6c2752c47de9dda0 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Wed, 5 Jun 2024 16:44:09 -0400 Subject: [PATCH] [AMDGPU] Add a new target gfx1152 --- clang/include/clang/Basic/Cuda.h | 1 + clang/lib/Basic/Cuda.cpp | 1 + clang/lib/Basic/Targets/NVPTX.cpp | 1 + clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 1 + clang/test/CodeGenOpenCL/amdgpu-features.cl | 2 ++ clang/test/CodeGenOpenCL/builtins-amdgcn-gfx11.cl | 1 + clang/test/Driver/amdgpu-macros.cl| 1 + clang/test/Driver/amdgpu-mcpu.cl | 2 ++ clang/test/Misc/target-invalid-cpu-note.c | 4 ++-- libclc/CMakeLists.txt | 2 +- llvm/docs/AMDGPUUsage.rst | 15 +-- llvm/include/llvm/BinaryFormat/ELF.h | 1 + llvm/include/llvm/TargetParser/TargetParser.h | 1 + llvm/lib/Object/ELFObjectFile.cpp | 2 ++ llvm/lib/ObjectYAML/ELFYAML.cpp | 1 + llvm/lib/Target/AMDGPU/AMDGPU.td | 6 ++ llvm/lib/Target/AMDGPU/GCNProcessors.td | 6 +- .../AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp | 2 ++ llvm/lib/TargetParser/TargetParser.cpp| 4 .../CodeGen/AMDGPU/directive-amdgcn-target.ll | 2 ++ llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll | 2 ++ llvm/test/CodeGen/AMDGPU/occupancy-levels.ll | 2 ++ llvm/test/MC/AMDGPU/gfx1150_asm_features.s| 1 + .../test/Object/AMDGPU/elf-header-flags-mach.yaml | 7 +++ .../tools/llvm-objdump/ELF/AMDGPU/subtarget.ll| 5 + .../llvm-readobj/ELF/AMDGPU/elf-headers.test | 9 + llvm/tools/llvm-readobj/ELFDumper.cpp | 1 + offload/DeviceRTL/CMakeLists.txt | 2 +- 28 files changed, 78 insertions(+), 7 deletions(-) diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h index d15171d959c45..0d5e38e825aa7 100644 --- a/clang/include/clang/Basic/Cuda.h +++ b/clang/include/clang/Basic/Cuda.h @@ -124,6 +124,7 @@ enum class CudaArch { GFX1103, GFX1150, GFX1151, + GFX1152, GFX12_GENERIC, GFX1200, GFX1201, diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp index e2609b9573cca..1d96a929f95d8 100644 --- a/clang/lib/Basic/Cuda.cpp +++ b/clang/lib/Basic/Cuda.cpp @@ -144,6 +144,7 @@ static const CudaArchToStringMap arch_names[] = { GFX(1103), // gfx1103 GFX(1150), // gfx1150 GFX(1151), // gfx1151 +GFX(1152), // gfx1152 {CudaArch::GFX12_GENERIC, "gfx12-generic", "compute_amdgcn"}, GFX(1200), // gfx1200 GFX(1201), // gfx1201 diff --git a/clang/lib/Basic/Targets/NVPTX.cpp b/clang/lib/Basic/Targets/NVPTX.cpp index fc6ef1119e9cf..ff7d2f1f92aa4 100644 --- a/clang/lib/Basic/Targets/NVPTX.cpp +++ b/clang/lib/Basic/Targets/NVPTX.cpp @@ -228,6 +228,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions , case CudaArch::GFX1103: case CudaArch::GFX1150: case CudaArch::GFX1151: + case CudaArch::GFX1152: case CudaArch::GFX12_GENERIC: case CudaArch::GFX1200: case CudaArch::GFX1201: diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index 191bd757831fc..6e9a1bacd9bf5 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -3537,6 +3537,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective( case CudaArch::GFX1103: case CudaArch::GFX1150: case CudaArch::GFX1151: + case CudaArch::GFX1152: case CudaArch::GFX12_GENERIC: case CudaArch::GFX1200: case CudaArch::GFX1201: diff --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl b/clang/test/CodeGenOpenCL/amdgpu-features.cl index 2fda52dcd2dc6..854ab39791f16 100644 --- a/clang/test/CodeGenOpenCL/amdgpu-features.cl +++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl @@ -49,6 +49,7 @@ // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1103 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1103 %s // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1150 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1150 %s // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1151 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1151 %s +// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1152 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1152 %s // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1200 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1200 %s // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1201 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1201 %s @@ -100,6 +101,7 @@ // GFX1103:
[clang] [libclc] [llvm] [AMDGPU] Add a new target gfx1152 (PR #94534)
https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/94534 None >From cf1e045d09d18f19bef4a8eb07f86e00f3b6f7a6 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Wed, 5 Jun 2024 16:18:57 -0400 Subject: [PATCH] [AMDGPU] Add a new target gfx1152 --- clang/include/clang/Basic/Cuda.h | 1 + clang/lib/Basic/Cuda.cpp | 1 + clang/lib/Basic/Targets/NVPTX.cpp | 1 + clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 1 + clang/test/CodeGenOpenCL/amdgpu-features.cl | 2 ++ clang/test/CodeGenOpenCL/builtins-amdgcn-gfx11.cl | 1 + clang/test/Driver/amdgpu-macros.cl| 1 + clang/test/Driver/amdgpu-mcpu.cl | 2 ++ clang/test/Misc/target-invalid-cpu-note.c | 4 ++-- libclc/CMakeLists.txt | 2 +- llvm/docs/AMDGPUUsage.rst | 15 +-- llvm/include/llvm/BinaryFormat/ELF.h | 1 + llvm/include/llvm/TargetParser/TargetParser.h | 1 + llvm/lib/Object/ELFObjectFile.cpp | 2 ++ llvm/lib/ObjectYAML/ELFYAML.cpp | 1 + llvm/lib/Target/AMDGPU/AMDGPU.td | 6 ++ llvm/lib/Target/AMDGPU/GCNProcessors.td | 6 +- .../AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp | 2 ++ llvm/lib/TargetParser/TargetParser.cpp| 4 .../CodeGen/AMDGPU/directive-amdgcn-target.ll | 2 ++ llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll | 2 ++ llvm/test/CodeGen/AMDGPU/occupancy-levels.ll | 2 ++ llvm/test/MC/AMDGPU/gfx1150_asm_features.s| 1 + .../test/Object/AMDGPU/elf-header-flags-mach.yaml | 7 +++ .../tools/llvm-objdump/ELF/AMDGPU/subtarget.ll| 5 + .../llvm-readobj/ELF/AMDGPU/elf-headers.test | 9 + llvm/tools/llvm-readobj/ELFDumper.cpp | 1 + offload/DeviceRTL/CMakeLists.txt | 2 +- 28 files changed, 78 insertions(+), 7 deletions(-) diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h index d15171d959c45..0d5e38e825aa7 100644 --- a/clang/include/clang/Basic/Cuda.h +++ b/clang/include/clang/Basic/Cuda.h @@ -124,6 +124,7 @@ enum class CudaArch { GFX1103, GFX1150, GFX1151, + GFX1152, GFX12_GENERIC, GFX1200, GFX1201, diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp index e2609b9573cca..1d96a929f95d8 100644 --- a/clang/lib/Basic/Cuda.cpp +++ b/clang/lib/Basic/Cuda.cpp @@ -144,6 +144,7 @@ static const CudaArchToStringMap arch_names[] = { GFX(1103), // gfx1103 GFX(1150), // gfx1150 GFX(1151), // gfx1151 +GFX(1152), // gfx1152 {CudaArch::GFX12_GENERIC, "gfx12-generic", "compute_amdgcn"}, GFX(1200), // gfx1200 GFX(1201), // gfx1201 diff --git a/clang/lib/Basic/Targets/NVPTX.cpp b/clang/lib/Basic/Targets/NVPTX.cpp index fc6ef1119e9cf..ff7d2f1f92aa4 100644 --- a/clang/lib/Basic/Targets/NVPTX.cpp +++ b/clang/lib/Basic/Targets/NVPTX.cpp @@ -228,6 +228,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions , case CudaArch::GFX1103: case CudaArch::GFX1150: case CudaArch::GFX1151: + case CudaArch::GFX1152: case CudaArch::GFX12_GENERIC: case CudaArch::GFX1200: case CudaArch::GFX1201: diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index 191bd757831fc..6e9a1bacd9bf5 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -3537,6 +3537,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective( case CudaArch::GFX1103: case CudaArch::GFX1150: case CudaArch::GFX1151: + case CudaArch::GFX1152: case CudaArch::GFX12_GENERIC: case CudaArch::GFX1200: case CudaArch::GFX1201: diff --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl b/clang/test/CodeGenOpenCL/amdgpu-features.cl index 2fda52dcd2dc6..854ab39791f16 100644 --- a/clang/test/CodeGenOpenCL/amdgpu-features.cl +++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl @@ -49,6 +49,7 @@ // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1103 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1103 %s // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1150 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1150 %s // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1151 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1151 %s +// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1152 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1152 %s // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1200 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1200 %s // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1201 -emit-llvm -o - %s | FileCheck --check-prefix=GFX1201 %s @@ -100,6 +101,7 @@ // GFX1103:
[clang] AMDGPU: Add missing gfx* generic targets handling in clang (NVPTX, OpenMP runtime) (PR #94483)
https://github.com/shiltian approved this pull request. https://github.com/llvm/llvm-project/pull/94483 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] AMDGPU: Add missing gfx* generic targets handling in clang (NVPTX, OpenMP runtime) (PR #94483)
@@ -121,6 +121,11 @@ enum class CudaArch { GFX1151, GFX1200, GFX1201, + GFX9_GENERIC, shiltian wrote: I think you might want to group them with corresponding non-generic targets such that we can directly use `>=` and `<=` to compare if a GFX version falls into one category if necessary. I'm not sure if we have this kind of use case, but it is common for the other targets. Ignore this if we don't. https://github.com/llvm/llvm-project/pull/94483 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Use `I` to decorate imm argument for `__builtin_amdgcn_global_load_lds` (PR #94376)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94376 >From d5ecf4e5f3cd5b7191acf3fd24ef0ac98b8a9f3e Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Tue, 4 Jun 2024 15:10:08 -0400 Subject: [PATCH] [Clang][AMDGPU] Use `I` to decorate imm argument for `__builtin_amdgcn_global_load_lds` --- clang/include/clang/Basic/BuiltinsAMDGPU.def| 2 +- clang/lib/Sema/SemaAMDGPU.cpp | 3 +-- clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl | 6 -- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 433c7795325f0..9e6800ea814a0 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -240,7 +240,7 @@ TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fadd_v2bf16, "V2sV2s*0V2s", "t", "at TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_v2bf16, "V2sV2s*1V2s", "t", "atomic-global-pk-add-bf16-inst") TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2bf16, "V2sV2s*3V2s", "t", "atomic-ds-pk-add-16-insts") TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2f16, "V2hV2h*3V2h", "t", "atomic-ds-pk-add-16-insts") -TARGET_BUILTIN(__builtin_amdgcn_global_load_lds, "vv*1v*3UiiUi", "t", "gfx940-insts") +TARGET_BUILTIN(__builtin_amdgcn_global_load_lds, "vv*1v*3IUiIiIUi", "t", "gfx940-insts") //===--===// // Deep learning builtins. diff --git a/clang/lib/Sema/SemaAMDGPU.cpp b/clang/lib/Sema/SemaAMDGPU.cpp index c446cc1d042a4..51d4f0d3d9648 100644 --- a/clang/lib/Sema/SemaAMDGPU.cpp +++ b/clang/lib/Sema/SemaAMDGPU.cpp @@ -32,8 +32,7 @@ bool SemaAMDGPU::CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, llvm::APSInt Size; Expr *ArgExpr = TheCall->getArg(SizeIdx); ExprResult R = SemaRef.VerifyIntegerConstantExpression(ArgExpr, ); -if (R.isInvalid()) - return true; +assert(!R.isInvalid()); switch (Size.getSExtValue()) { case 1: case 2: diff --git a/clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl b/clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl index 487cc53e8ad8a..2a1ba4300864c 100644 --- a/clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl +++ b/clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl @@ -3,8 +3,10 @@ typedef unsigned int u32; -void test_global_load_lds_unsupported_size(global u32* src, local u32 *dst, u32 size) { - __builtin_amdgcn_global_load_lds(src, dst, size, /*offset=*/0, /*aux=*/0); // expected-error{{expression is not an integer constant expression}} +void test_global_load_lds_unsupported_size(global u32* src, local u32 *dst, u32 size, u32 offset, u32 aux) { + __builtin_amdgcn_global_load_lds(src, dst, size, /*offset=*/0, /*aux=*/0); // expected-error{{argument to '__builtin_amdgcn_global_load_lds' must be a constant integer}} + __builtin_amdgcn_global_load_lds(src, dst, /*size=*/4, offset, /*aux=*/0); // expected-error{{argument to '__builtin_amdgcn_global_load_lds' must be a constant integer}} + __builtin_amdgcn_global_load_lds(src, dst, /*size=*/4, /*offset=*/0, aux); // expected-error{{argument to '__builtin_amdgcn_global_load_lds' must be a constant integer}} __builtin_amdgcn_global_load_lds(src, dst, /*size=*/5, /*offset=*/0, /*aux=*/0); // expected-error{{invalid size value}} expected-note {{size must be 1, 2, or 4}} __builtin_amdgcn_global_load_lds(src, dst, /*size=*/0, /*offset=*/0, /*aux=*/0); // expected-error{{invalid size value}} expected-note {{size must be 1, 2, or 4}} __builtin_amdgcn_global_load_lds(src, dst, /*size=*/3, /*offset=*/0, /*aux=*/0); // expected-error{{invalid size value}} expected-note {{size must be 1, 2, or 4}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Use `I` to decorate imm argument for `__builtin_amdgcn_global_load_lds` (PR #94376)
https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/94376 None >From d974ef91f988f803e5904d4b922e8b65390d16a0 Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Tue, 4 Jun 2024 12:26:32 -0400 Subject: [PATCH] [Clang][AMDGPU] Use `I` to decorate imm argument for `__builtin_amdgcn_global_load_lds` --- clang/include/clang/Basic/BuiltinsAMDGPU.def| 2 +- clang/lib/Sema/SemaAMDGPU.cpp | 3 +-- clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 433c7795325f0..9e6800ea814a0 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -240,7 +240,7 @@ TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fadd_v2bf16, "V2sV2s*0V2s", "t", "at TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_v2bf16, "V2sV2s*1V2s", "t", "atomic-global-pk-add-bf16-inst") TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2bf16, "V2sV2s*3V2s", "t", "atomic-ds-pk-add-16-insts") TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2f16, "V2hV2h*3V2h", "t", "atomic-ds-pk-add-16-insts") -TARGET_BUILTIN(__builtin_amdgcn_global_load_lds, "vv*1v*3UiiUi", "t", "gfx940-insts") +TARGET_BUILTIN(__builtin_amdgcn_global_load_lds, "vv*1v*3IUiIiIUi", "t", "gfx940-insts") //===--===// // Deep learning builtins. diff --git a/clang/lib/Sema/SemaAMDGPU.cpp b/clang/lib/Sema/SemaAMDGPU.cpp index c446cc1d042a4..51d4f0d3d9648 100644 --- a/clang/lib/Sema/SemaAMDGPU.cpp +++ b/clang/lib/Sema/SemaAMDGPU.cpp @@ -32,8 +32,7 @@ bool SemaAMDGPU::CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, llvm::APSInt Size; Expr *ArgExpr = TheCall->getArg(SizeIdx); ExprResult R = SemaRef.VerifyIntegerConstantExpression(ArgExpr, ); -if (R.isInvalid()) - return true; +assert(!R.isInvalid()); switch (Size.getSExtValue()) { case 1: case 2: diff --git a/clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl b/clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl index 487cc53e8ad8a..05fff32d4dce7 100644 --- a/clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl +++ b/clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl @@ -4,7 +4,7 @@ typedef unsigned int u32; void test_global_load_lds_unsupported_size(global u32* src, local u32 *dst, u32 size) { - __builtin_amdgcn_global_load_lds(src, dst, size, /*offset=*/0, /*aux=*/0); // expected-error{{expression is not an integer constant expression}} + __builtin_amdgcn_global_load_lds(src, dst, size, /*offset=*/0, /*aux=*/0); // expected-error{{argument to '__builtin_amdgcn_global_load_lds' must be a constant integer}} __builtin_amdgcn_global_load_lds(src, dst, /*size=*/5, /*offset=*/0, /*aux=*/0); // expected-error{{invalid size value}} expected-note {{size must be 1, 2, or 4}} __builtin_amdgcn_global_load_lds(src, dst, /*size=*/0, /*offset=*/0, /*aux=*/0); // expected-error{{invalid size value}} expected-note {{size must be 1, 2, or 4}} __builtin_amdgcn_global_load_lds(src, dst, /*size=*/3, /*offset=*/0, /*aux=*/0); // expected-error{{invalid size value}} expected-note {{size must be 1, 2, or 4}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] AMDGPU: Add gfx12-generic target (PR #93875)
https://github.com/shiltian approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/93875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] AMDGPU: Add gfx12-generic target (PR #93875)
https://github.com/shiltian deleted https://github.com/llvm/llvm-project/pull/93875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] AMDGPU: Add gfx12-generic target (PR #93875)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/93875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits