Skip to content

Commit b8c63d6

Browse files
committed
[Clang][RISCV] Implement __builtin_riscv_pause intrinsic
1 parent e05e3cf commit b8c63d6

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

clang/include/clang/Basic/BuiltinsRISCV.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ def ntl_load : RISCVBuiltin<"void(...)">;
147147
def ntl_store : RISCVBuiltin<"void(...)">;
148148
} // Features = "zihintntl", Attributes = [CustomTypeChecking]
149149

150+
//===----------------------------------------------------------------------===//
151+
// Zihintpause extension.
152+
//===----------------------------------------------------------------------===//
153+
let Features = "zihintpause" in {
154+
def pause : RISCVBuiltin<"void(...)">;
155+
} // Features = "zihintntl"
156+
150157
//===----------------------------------------------------------------------===//
151158
// XCV extensions.
152159
//===----------------------------------------------------------------------===//

clang/lib/CodeGen/TargetBuiltins/RISCV.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,12 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID,
357357

358358
return Store;
359359
}
360+
// Zihintpause
361+
case RISCV::BI__builtin_riscv_pause: {
362+
llvm::Function *Fn = CGM.getIntrinsic(llvm::Intrinsic::riscv_pause);
363+
return Builder.CreateCall(Fn, {});
364+
}
365+
360366
// XCValu
361367
case RISCV::BI__builtin_riscv_cv_alu_addN:
362368
ID = Intrinsic::riscv_cv_alu_addN;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2+
// RUN: %clang_cc1 -triple riscv32 -target-feature +zihintpause -emit-llvm %s -o - \
3+
// RUN: | FileCheck %s
4+
5+
#include <stdint.h>
6+
7+
// CHECK-LABEL: @test_builtin_pause(
8+
// CHECK-NEXT: entry:
9+
// CHECK-NEXT: call void @llvm.riscv.pause()
10+
// CHECK-NEXT: ret void
11+
//
12+
void test_builtin_pause() {
13+
__builtin_riscv_pause();
14+
}

0 commit comments

Comments
 (0)