Changeset View
Changeset View
Standalone View
Standalone View
lib/CodeGen/CGBuiltin.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 6,570 Lines • ▼ Show 20 Lines | if (BuiltinID == AArch64::BI__builtin_arm_strex || | ||||
Function *F = CGM.getIntrinsic(BuiltinID == AArch64::BI__builtin_arm_stlex | Function *F = CGM.getIntrinsic(BuiltinID == AArch64::BI__builtin_arm_stlex | ||||
? Intrinsic::aarch64_stlxr | ? Intrinsic::aarch64_stlxr | ||||
: Intrinsic::aarch64_stxr, | : Intrinsic::aarch64_stxr, | ||||
StoreAddr->getType()); | StoreAddr->getType()); | ||||
return Builder.CreateCall(F, {StoreVal, StoreAddr}, "stxr"); | return Builder.CreateCall(F, {StoreVal, StoreAddr}, "stxr"); | ||||
} | } | ||||
if (BuiltinID == AArch64::BI__getReg) { | |||||
APSInt Value; | |||||
if (!E->getArg(0)->EvaluateAsInt(Value, CGM.getContext())) | |||||
llvm_unreachable("Sema will ensure that the parameter is constant"); | |||||
efriedma: Semantic checks belong in SemaChecking, not here. IIRC you can request constant checking in… | |||||
LLVMContext &Context = CGM.getLLVMContext(); | |||||
std::string Reg = Value == 31 ? "sp" : "x" + Value.toString(10); | |||||
llvm::Metadata *Ops[] = {llvm::MDString::get(Context, Reg)}; | |||||
llvm::MDNode *RegName = llvm::MDNode::get(Context, Ops); | |||||
llvm::Value *Metadata = llvm::MetadataAsValue::get(Context, RegName); | |||||
Could you just write this as std::string Reg = Value == 31 ? "sp" : "x" + Value.toString(10);, and get rid of StrVal? efriedma: Could you just write this as `std::string Reg = Value == 31 ? "sp" : "x" + Value.toString(10);`… | |||||
llvm::Value *F = | |||||
CGM.getIntrinsic(llvm::Intrinsic::read_register, {Int64Ty}); | |||||
There is no register named x31. Maybe you need a special case here to use "sp" if the input is 31? efriedma: There is no register named x31. Maybe you need a special case here to use "sp" if the input is… | |||||
return Builder.CreateCall(F, Metadata); | |||||
} | |||||
if (BuiltinID == AArch64::BI__builtin_arm_clrex) { | if (BuiltinID == AArch64::BI__builtin_arm_clrex) { | ||||
Function *F = CGM.getIntrinsic(Intrinsic::aarch64_clrex); | Function *F = CGM.getIntrinsic(Intrinsic::aarch64_clrex); | ||||
return Builder.CreateCall(F); | return Builder.CreateCall(F); | ||||
} | } | ||||
if (BuiltinID == AArch64::BI_ReadWriteBarrier) | if (BuiltinID == AArch64::BI_ReadWriteBarrier) | ||||
return Builder.CreateFence(llvm::AtomicOrdering::SequentiallyConsistent, | return Builder.CreateFence(llvm::AtomicOrdering::SequentiallyConsistent, | ||||
llvm::SyncScope::SingleThread); | llvm::SyncScope::SingleThread); | ||||
▲ Show 20 Lines • Show All 6,048 Lines • Show Last 20 Lines |
Semantic checks belong in SemaChecking, not here. IIRC you can request constant checking in the .def file, although I don't remember the syntax off the top of my head.