diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp --- a/clang/lib/Basic/Targets/RISCV.cpp +++ b/clang/lib/Basic/Targets/RISCV.cpp @@ -105,7 +105,7 @@ std::string R; switch (*Constraint) { case 'v': - R = std::string("v"); + R = std::string("^") + std::string(Constraint, 2); Constraint += 1; break; default: diff --git a/clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c b/clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c --- a/clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c +++ b/clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c @@ -21,7 +21,7 @@ vint32m1_t test_vr(vint32m1_t a, vint32m1_t b) { // CHECK-LABEL: define{{.*}} @test_vr -// CHECK: %0 = tail call asm sideeffect "vadd.vv $0, $1, $2", "=v,v,v"( %a, %b) +// CHECK: %0 = tail call asm sideeffect "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %a, %b) vint32m1_t ret; asm volatile ("vadd.vv %0, %1, %2" : "=vr"(ret) : "vr"(a), "vr"(b)); return ret; @@ -29,7 +29,7 @@ vbool1_t test_vm(vbool1_t a, vbool1_t b) { // CHECK-LABEL: define{{.*}} @test_vm -// CHECK: %0 = tail call asm sideeffect "vmand.mm $0, $1, $2", "=v,v,v"( %a, %b) +// CHECK: %0 = tail call asm sideeffect "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %a, %b) vbool1_t ret; asm volatile ("vmand.mm %0, %1, %2" : "=vm"(ret) : "vm"(a), "vm"(b)); return ret; diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -8473,7 +8473,6 @@ default: break; case 'f': - case 'v': return C_RegisterClass; case 'I': case 'J': @@ -8484,6 +8483,9 @@ case 'S': // A symbolic address return C_Other; } + } else { + if (Constraint == "vr" || Constraint == "vm") + return C_RegisterClass; } return TargetLowering::getConstraintType(Constraint); } @@ -8506,16 +8508,19 @@ if (Subtarget.hasStdExtD() && VT == MVT::f64) return std::make_pair(0U, &RISCV::FPR64RegClass); break; - case 'v': - for (const auto *RC : - {&RISCV::VMRegClass, &RISCV::VRRegClass, &RISCV::VRM2RegClass, - &RISCV::VRM4RegClass, &RISCV::VRM8RegClass}) { + default: + break; + } + } else { + if (Constraint == "vr") { + for (const auto *RC : {&RISCV::VRRegClass, &RISCV::VRM2RegClass, + &RISCV::VRM4RegClass, &RISCV::VRM8RegClass}) { if (TRI->isTypeLegalForClass(*RC, VT.SimpleTy)) return std::make_pair(0U, RC); } - break; - default: - break; + } else if (Constraint == "vm") { + if (TRI->isTypeLegalForClass(RISCV::VMRegClass, VT.SimpleTy)) + return std::make_pair(0U, &RISCV::VMRegClass); } } diff --git a/llvm/test/CodeGen/RISCV/rvv/inline-asm.ll b/llvm/test/CodeGen/RISCV/rvv/inline-asm.ll --- a/llvm/test/CodeGen/RISCV/rvv/inline-asm.ll +++ b/llvm/test/CodeGen/RISCV/rvv/inline-asm.ll @@ -10,7 +10,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vmand.mm $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in, %in2) ret %0 } @@ -22,7 +22,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vmand.mm $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in, %in2) ret %0 } @@ -34,7 +34,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vmand.mm $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in, %in2) ret %0 } @@ -46,7 +46,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vmand.mm $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in, %in2) ret %0 } @@ -58,7 +58,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vmand.mm $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in, %in2) ret %0 } @@ -70,7 +70,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vmand.mm $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in, %in2) ret %0 } @@ -82,7 +82,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vmand.mm $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"( %in, %in2) ret %0 } @@ -94,7 +94,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -106,7 +106,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -118,7 +118,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -130,7 +130,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -142,7 +142,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -154,7 +154,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -166,7 +166,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -178,7 +178,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -190,7 +190,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -202,7 +202,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -214,7 +214,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -226,7 +226,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -238,7 +238,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -250,7 +250,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -262,7 +262,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -274,7 +274,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -286,7 +286,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -298,7 +298,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -310,7 +310,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -322,7 +322,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -334,7 +334,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 } @@ -346,7 +346,7 @@ ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: ret entry: - %0 = tail call asm "vadd.vv $0, $1, $2", "=v,v,v"( %in, %in2) + %0 = tail call asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( %in, %in2) ret %0 }