Author: yaxunl Date: Fri Mar 23 12:43:42 2018 New Revision: 328359 URL: http://llvm.org/viewvc/llvm-project?rev=328359&view=rev Log: [AMDGPU] Fix codegen for inline assembly
Need to override convertConstraint to recognise amdgpu specific register names. Differential Revision: https://reviews.llvm.org/D44533 Added: cfe/trunk/test/CodeGenOpenCL/inline-asm-amdgcn.cl Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.h cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.h?rev=328359&r1=328358&r2=328359&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets/AMDGPU.h (original) +++ cfe/trunk/lib/Basic/Targets/AMDGPU.h Fri Mar 23 12:43:42 2018 @@ -285,6 +285,19 @@ public: return true; } + // \p Constraint will be left pointing at the last character of + // the constraint. In practice, it won't be changed unless the + // constraint is longer than one character. + std::string convertConstraint(const char *&Constraint) const override { + const char *Begin = Constraint; + TargetInfo::ConstraintInfo Info("", ""); + if (validateAsmConstraint(Constraint, Info)) + return std::string(Begin).substr(0, Constraint - Begin + 1); + + Constraint = Begin; + return std::string(1, *Constraint); + } + bool initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU, Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=328359&r1=328358&r2=328359&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Mar 23 12:43:42 2018 @@ -1926,7 +1926,7 @@ void CodeGenFunction::EmitAsmStmt(const // Simplify the output constraint. std::string OutputConstraint(S.getOutputConstraint(i)); OutputConstraint = SimplifyConstraint(OutputConstraint.c_str() + 1, - getTarget()); + getTarget(), &OutputConstraintInfos); const Expr *OutExpr = S.getOutputExpr(i); OutExpr = OutExpr->IgnoreParenNoopCasts(getContext()); Added: cfe/trunk/test/CodeGenOpenCL/inline-asm-amdgcn.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/inline-asm-amdgcn.cl?rev=328359&view=auto ============================================================================== --- cfe/trunk/test/CodeGenOpenCL/inline-asm-amdgcn.cl (added) +++ cfe/trunk/test/CodeGenOpenCL/inline-asm-amdgcn.cl Fri Mar 23 12:43:42 2018 @@ -0,0 +1,8 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s + +kernel void test_long(int arg0) { + long v15_16; + // CHECK: tail call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", "={v[15:16]},v"(i32 %arg0) + __asm volatile("v_lshlrev_b64 v[15:16], 0, %0" : "={v[15:16]}"(v15_16) : "v"(arg0)); +} Modified: cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl?rev=328359&r1=328358&r2=328359&view=diff ============================================================================== --- cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl (original) +++ cfe/trunk/test/Sema/inline-asm-validate-amdgpu.cl Fri Mar 23 12:43:42 2018 @@ -74,3 +74,8 @@ test_double(const __global double *a, co c[i] = ci; } + +void test_long(int arg0) { + long v15_16; + __asm volatile("v_lshlrev_b64 v[15:16], 0, %0" : "={v[15:16]}"(v15_16) : "v"(arg0)); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits