mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-20 10:07:02 +00:00
Reland "[COFF, ARM64] Add __break intrinsic"
https://docs.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics?view=msvc-170 Reland after fixing the test failure. The failure was due to conflict with a change (D122983) which was merged right before this patch. Reviewed By: rnk, mstorsjo Differential Revision: https://reviews.llvm.org/D124032
This commit is contained in:
parent
af7b98c383
commit
38612fbc89
@ -249,6 +249,8 @@ TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", ALL_MS_LA
|
||||
TARGET_HEADER_BUILTIN(__mulh, "SLLiSLLiSLLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
|
||||
TARGET_HEADER_BUILTIN(__umulh, "ULLiULLiULLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
|
||||
|
||||
TARGET_HEADER_BUILTIN(__break, "vi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
|
||||
|
||||
#undef BUILTIN
|
||||
#undef LANGBUILTIN
|
||||
#undef TARGET_HEADER_BUILTIN
|
||||
|
@ -9823,6 +9823,15 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
|
||||
return Builder.CreateCall(F, Metadata);
|
||||
}
|
||||
|
||||
if (BuiltinID == AArch64::BI__break) {
|
||||
Expr::EvalResult Result;
|
||||
if (!E->getArg(0)->EvaluateAsInt(Result, CGM.getContext()))
|
||||
llvm_unreachable("Sema will ensure that the parameter is constant");
|
||||
|
||||
llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::aarch64_break);
|
||||
return Builder.CreateCall(F, {EmitScalarExpr(E->getArg(0))});
|
||||
}
|
||||
|
||||
if (BuiltinID == AArch64::BI__builtin_arm_clrex) {
|
||||
Function *F = CGM.getIntrinsic(Intrinsic::aarch64_clrex);
|
||||
return Builder.CreateCall(F);
|
||||
|
@ -560,6 +560,8 @@ unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64 val);
|
||||
|
||||
__int64 __mulh(__int64 __a, __int64 __b);
|
||||
unsigned __int64 __umulh(unsigned __int64 __a, unsigned __int64 __b);
|
||||
|
||||
void __break(int);
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
|
@ -2948,6 +2948,9 @@ bool Sema::CheckAArch64BuiltinFunctionCall(const TargetInfo &TI,
|
||||
if (BuiltinID == AArch64::BI__getReg)
|
||||
return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31);
|
||||
|
||||
if (BuiltinID == AArch64::BI__break)
|
||||
return SemaBuiltinConstantArgRange(TheCall, 0, 0, 0xffff);
|
||||
|
||||
if (CheckNeonBuiltinFunctionCall(TI, BuiltinID, TheCall))
|
||||
return true;
|
||||
|
||||
|
@ -103,6 +103,13 @@ unsigned long long check_umulh(unsigned long long a, unsigned long long b) {
|
||||
// CHECK-MSVC: %[[RES:.*]] = trunc i128 %[[HIGH]] to i64
|
||||
// CHECK-LINUX: error: call to undeclared function '__umulh'
|
||||
|
||||
void check__break() {
|
||||
__break(0);
|
||||
}
|
||||
|
||||
// CHECK-MSVC: call void @llvm.aarch64.break(i32 0)
|
||||
// CHECK-LINUX: error: call to undeclared function '__break'
|
||||
|
||||
unsigned __int64 check__getReg(void) {
|
||||
unsigned volatile __int64 reg;
|
||||
reg = __getReg(18);
|
||||
|
@ -3,6 +3,12 @@
|
||||
|
||||
#include <intrin.h>
|
||||
|
||||
void check__break(int x) {
|
||||
__break(-1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
||||
__break(65536); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
||||
__break(x); // expected-error {{argument to '__break' must be a constant integer}}
|
||||
}
|
||||
|
||||
void check__getReg(void) {
|
||||
__getReg(-1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
||||
__getReg(32); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
||||
|
@ -62,6 +62,9 @@ def int_aarch64_frint64x
|
||||
|
||||
def int_aarch64_hint : DefaultAttrsIntrinsic<[], [llvm_i32_ty]>;
|
||||
|
||||
def int_aarch64_break : Intrinsic<[], [llvm_i32_ty],
|
||||
[IntrNoMem, IntrHasSideEffects, IntrNoReturn, IntrCold, ImmArg<ArgIndex<0>>]>;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Data Barrier Instructions
|
||||
|
||||
|
@ -4529,8 +4529,9 @@ multiclass MemTagStore<bits<2> opc1, string insn> {
|
||||
//---
|
||||
|
||||
let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
|
||||
class ExceptionGeneration<bits<3> op1, bits<2> ll, string asm>
|
||||
: I<(outs), (ins timm32_0_65535:$imm), asm, "\t$imm", "", []>,
|
||||
class ExceptionGeneration<bits<3> op1, bits<2> ll, string asm,
|
||||
list<dag> pattern = []>
|
||||
: I<(outs), (ins timm32_0_65535:$imm), asm, "\t$imm", "", pattern>,
|
||||
Sched<[WriteSys]> {
|
||||
bits<16> imm;
|
||||
let Inst{31-24} = 0b11010100;
|
||||
|
@ -2432,7 +2432,8 @@ def : Pat<(AArch64call texternalsym:$func), (BL texternalsym:$func)>;
|
||||
// Exception generation instructions.
|
||||
//===----------------------------------------------------------------------===//
|
||||
let isTrap = 1 in {
|
||||
def BRK : ExceptionGeneration<0b001, 0b00, "brk">;
|
||||
def BRK : ExceptionGeneration<0b001, 0b00, "brk",
|
||||
[(int_aarch64_break timm32_0_65535:$imm)]>;
|
||||
}
|
||||
def DCPS1 : ExceptionGeneration<0b101, 0b01, "dcps1">;
|
||||
def DCPS2 : ExceptionGeneration<0b101, 0b10, "dcps2">;
|
||||
|
10
llvm/test/CodeGen/AArch64/arm64-break.ll
Normal file
10
llvm/test/CodeGen/AArch64/arm64-break.ll
Normal file
@ -0,0 +1,10 @@
|
||||
; RUN: llc < %s -mtriple=arm64-eabi | FileCheck %s
|
||||
|
||||
define void @foo() nounwind {
|
||||
; CHECK-LABEL: foo
|
||||
; CHECK: brk #0x2
|
||||
tail call void @llvm.aarch64.break(i32 2)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @llvm.aarch64.break(i32 immarg) nounwind
|
Loading…
x
Reference in New Issue
Block a user