Skip to content

Commit bf02f12

Browse files
author
Changpeng Fang
committed
AMDGPU: Add clang builtin for ds_swizzle.
Summary: int __builtin_amdgcn_ds_swizzle (int a, int imm); while imm is a constant. Differential Revision: http://reviews.llvm.org/D23682 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@279165 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 4453feb commit bf02f12

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ BUILTIN(__builtin_amdgcn_sicmp, "LUiiiIi", "nc")
7676
BUILTIN(__builtin_amdgcn_sicmpl, "LUiLiLiIi", "nc")
7777
BUILTIN(__builtin_amdgcn_fcmp, "LUiddIi", "nc")
7878
BUILTIN(__builtin_amdgcn_fcmpf, "LUiffIi", "nc")
79+
BUILTIN(__builtin_amdgcn_ds_swizzle, "iiIi", "nc")
7980

8081
//===----------------------------------------------------------------------===//
8182
// VI+ only builtins.

lib/CodeGen/CGBuiltin.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7652,6 +7652,9 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
76527652
llvm::Value *Src3ToBool = Builder.CreateIsNotNull(Src3);
76537653
return Builder.CreateCall(F, {Src0, Src1, Src2, Src3ToBool});
76547654
}
7655+
7656+
case AMDGPU::BI__builtin_amdgcn_ds_swizzle:
7657+
return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_swizzle);
76557658
case AMDGPU::BI__builtin_amdgcn_div_fixup:
76567659
case AMDGPU::BI__builtin_amdgcn_div_fixupf:
76577660
return emitTernaryBuiltin(*this, E, Intrinsic::amdgcn_div_fixup);

test/CodeGenOpenCL/builtins-amdgcn-error.cl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ void test_fcmp_f64(global ulong* out, double a, double b, uint c)
4848
*out = __builtin_amdgcn_fcmp(a, b, c); // expected-error {{argument to '__builtin_amdgcn_fcmp' must be a constant integer}}
4949
}
5050

51+
void test_ds_swizzle(global int* out, int a, int b)
52+
{
53+
*out = __builtin_amdgcn_ds_swizzle(a, b); // expected-error {{argument to '__builtin_amdgcn_ds_swizzle' must be a constant integer}}
54+
}

test/CodeGenOpenCL/builtins-amdgcn.cl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ void test_uicmp_i64(global ulong* out, ulong a, ulong b)
228228
*out = __builtin_amdgcn_uicmpl(a, b, 30+5);
229229
}
230230

231+
// CHECK-LABEL: @test_ds_swizzle
232+
// CHECK: call i32 @llvm.amdgcn.ds.swizzle(i32 %a, i32 32)
233+
void test_ds_swizzle(global int* out, int a)
234+
{
235+
*out = __builtin_amdgcn_ds_swizzle(a, 32);
236+
}
237+
231238
// CHECK-LABEL: @test_fcmp_f32
232239
// CHECK: call i64 @llvm.amdgcn.fcmp.f32(float %a, float %b, i32 5)
233240
void test_fcmp_f32(global ulong* out, float a, float b)

0 commit comments

Comments
 (0)