15#include "llvm/IR/IntrinsicsS390.h"
18using namespace CodeGen;
27 unsigned NumArgs =
E->getNumArgs() - 1;
29 for (
unsigned I = 0; I < NumArgs; ++I)
42 case SystemZ::BI__builtin_tbegin: {
44 Value *Control = llvm::ConstantInt::get(
Int32Ty, 0xff0c);
46 return Builder.CreateCall(F, {TDB, Control});
48 case SystemZ::BI__builtin_tbegin_nofloat: {
50 Value *Control = llvm::ConstantInt::get(
Int32Ty, 0xff0c);
52 return Builder.CreateCall(F, {TDB, Control});
54 case SystemZ::BI__builtin_tbeginc: {
56 Value *Control = llvm::ConstantInt::get(
Int32Ty, 0xff08);
58 return Builder.CreateCall(F, {TDB, Control});
60 case SystemZ::BI__builtin_tabort: {
65 case SystemZ::BI__builtin_non_tx_store: {
77 case SystemZ::BI__builtin_s390_vclzb:
78 case SystemZ::BI__builtin_s390_vclzh:
79 case SystemZ::BI__builtin_s390_vclzf:
80 case SystemZ::BI__builtin_s390_vclzg:
81 case SystemZ::BI__builtin_s390_vclzq: {
84 Value *Undef = ConstantInt::get(
Builder.getInt1Ty(),
false);
86 return Builder.CreateCall(F, {
X, Undef});
89 case SystemZ::BI__builtin_s390_vctzb:
90 case SystemZ::BI__builtin_s390_vctzh:
91 case SystemZ::BI__builtin_s390_vctzf:
92 case SystemZ::BI__builtin_s390_vctzg:
93 case SystemZ::BI__builtin_s390_vctzq: {
96 Value *Undef = ConstantInt::get(
Builder.getInt1Ty(),
false);
98 return Builder.CreateCall(F, {
X, Undef});
101 case SystemZ::BI__builtin_s390_verllb:
102 case SystemZ::BI__builtin_s390_verllh:
103 case SystemZ::BI__builtin_s390_verllf:
104 case SystemZ::BI__builtin_s390_verllg: {
109 unsigned NumElts = cast<llvm::FixedVectorType>(ResultType)->getNumElements();
110 Amt =
Builder.CreateIntCast(Amt, ResultType->getScalarType(),
false);
111 Amt =
Builder.CreateVectorSplat(NumElts, Amt);
113 return Builder.CreateCall(F, { Src, Src, Amt });
116 case SystemZ::BI__builtin_s390_verllvb:
117 case SystemZ::BI__builtin_s390_verllvh:
118 case SystemZ::BI__builtin_s390_verllvf:
119 case SystemZ::BI__builtin_s390_verllvg: {
124 return Builder.CreateCall(F, { Src, Src, Amt });
127 case SystemZ::BI__builtin_s390_vfsqsb:
128 case SystemZ::BI__builtin_s390_vfsqdb: {
131 if (
Builder.getIsFPConstrained()) {
133 return Builder.CreateConstrainedFPCall(F, {
X });
139 case SystemZ::BI__builtin_s390_vfmasb:
140 case SystemZ::BI__builtin_s390_vfmadb: {
145 if (
Builder.getIsFPConstrained()) {
147 return Builder.CreateConstrainedFPCall(F, {
X, Y, Z});
150 return Builder.CreateCall(F, {
X, Y, Z});
153 case SystemZ::BI__builtin_s390_vfmssb:
154 case SystemZ::BI__builtin_s390_vfmsdb: {
159 if (
Builder.getIsFPConstrained()) {
161 return Builder.CreateConstrainedFPCall(F, {
X, Y,
Builder.CreateFNeg(Z,
"neg")});
167 case SystemZ::BI__builtin_s390_vfnmasb:
168 case SystemZ::BI__builtin_s390_vfnmadb: {
173 if (
Builder.getIsFPConstrained()) {
175 return Builder.CreateFNeg(
Builder.CreateConstrainedFPCall(F, {X, Y, Z}),
"neg");
178 return Builder.CreateFNeg(
Builder.CreateCall(F, {X, Y, Z}),
"neg");
181 case SystemZ::BI__builtin_s390_vfnmssb:
182 case SystemZ::BI__builtin_s390_vfnmsdb: {
187 if (
Builder.getIsFPConstrained()) {
190 return Builder.CreateFNeg(
Builder.CreateConstrainedFPCall(F, {X, Y, NegZ}));
197 case SystemZ::BI__builtin_s390_vflpsb:
198 case SystemZ::BI__builtin_s390_vflpdb: {
204 case SystemZ::BI__builtin_s390_vflnsb:
205 case SystemZ::BI__builtin_s390_vflndb: {
211 case SystemZ::BI__builtin_s390_vfisb:
212 case SystemZ::BI__builtin_s390_vfidb: {
220 Intrinsic::ID ID = Intrinsic::not_intrinsic;
222 switch (M4.getZExtValue()) {
225 switch (M5.getZExtValue()) {
227 case 0: ID = Intrinsic::rint;
228 CI = Intrinsic::experimental_constrained_rint;
break;
232 switch (M5.getZExtValue()) {
234 case 0: ID = Intrinsic::nearbyint;
235 CI = Intrinsic::experimental_constrained_nearbyint;
break;
236 case 1: ID = Intrinsic::round;
237 CI = Intrinsic::experimental_constrained_round;
break;
238 case 4: ID = Intrinsic::roundeven;
239 CI = Intrinsic::experimental_constrained_roundeven;
break;
240 case 5: ID = Intrinsic::trunc;
241 CI = Intrinsic::experimental_constrained_trunc;
break;
242 case 6: ID = Intrinsic::ceil;
243 CI = Intrinsic::experimental_constrained_ceil;
break;
244 case 7: ID = Intrinsic::floor;
245 CI = Intrinsic::experimental_constrained_floor;
break;
249 if (ID != Intrinsic::not_intrinsic) {
250 if (
Builder.getIsFPConstrained()) {
252 return Builder.CreateConstrainedFPCall(F,
X);
259 case SystemZ::BI__builtin_s390_vfisb: ID = Intrinsic::s390_vfisb;
break;
260 case SystemZ::BI__builtin_s390_vfidb: ID = Intrinsic::s390_vfidb;
break;
261 default: llvm_unreachable(
"Unknown BuiltinID");
266 return Builder.CreateCall(F, {
X, M4Value, M5Value});
268 case SystemZ::BI__builtin_s390_vfmaxsb:
269 case SystemZ::BI__builtin_s390_vfmaxdb: {
277 Intrinsic::ID ID = Intrinsic::not_intrinsic;
279 switch (M4.getZExtValue()) {
281 case 4: ID = Intrinsic::maxnum;
282 CI = Intrinsic::experimental_constrained_maxnum;
break;
284 if (ID != Intrinsic::not_intrinsic) {
285 if (
Builder.getIsFPConstrained()) {
287 return Builder.CreateConstrainedFPCall(F, {
X, Y});
290 return Builder.CreateCall(F, {
X, Y});
294 case SystemZ::BI__builtin_s390_vfmaxsb: ID = Intrinsic::s390_vfmaxsb;
break;
295 case SystemZ::BI__builtin_s390_vfmaxdb: ID = Intrinsic::s390_vfmaxdb;
break;
296 default: llvm_unreachable(
"Unknown BuiltinID");
300 return Builder.CreateCall(F, {
X, Y, M4Value});
302 case SystemZ::BI__builtin_s390_vfminsb:
303 case SystemZ::BI__builtin_s390_vfmindb: {
311 Intrinsic::ID ID = Intrinsic::not_intrinsic;
313 switch (M4.getZExtValue()) {
315 case 4: ID = Intrinsic::minnum;
316 CI = Intrinsic::experimental_constrained_minnum;
break;
318 if (ID != Intrinsic::not_intrinsic) {
319 if (
Builder.getIsFPConstrained()) {
321 return Builder.CreateConstrainedFPCall(F, {
X, Y});
324 return Builder.CreateCall(F, {
X, Y});
328 case SystemZ::BI__builtin_s390_vfminsb: ID = Intrinsic::s390_vfminsb;
break;
329 case SystemZ::BI__builtin_s390_vfmindb: ID = Intrinsic::s390_vfmindb;
break;
330 default: llvm_unreachable(
"Unknown BuiltinID");
334 return Builder.CreateCall(F, {
X, Y, M4Value});
337 case SystemZ::BI__builtin_s390_vlbrh:
338 case SystemZ::BI__builtin_s390_vlbrf:
339 case SystemZ::BI__builtin_s390_vlbrg:
340 case SystemZ::BI__builtin_s390_vlbrq: {
349#define INTRINSIC_WITH_CC(NAME) \
350 case SystemZ::BI__builtin_##NAME: \
351 return EmitSystemZIntrinsicWithCC(*this, Intrinsic::NAME, E)
433#undef INTRINSIC_WITH_CC
#define INTRINSIC_WITH_CC(NAME)
static Value * EmitSystemZIntrinsicWithCC(CodeGenFunction &CGF, unsigned IntrinsicID, const CallExpr *E)
Handle a SystemZ function in which the final argument is a pointer to an int that receives the post-i...
Enumerates target-specific builtins in their own namespaces within namespace clang.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::Type * ConvertType(QualType T)
llvm::Value * EmitSystemZBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
ASTContext & getContext() const
Address EmitPointerWithAlignment(const Expr *Addr, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
EmitPointerWithAlignment - Given an expression with a pointer type, emit the value and compute our be...
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type,...
llvm::LLVMContext & getLLVMContext()
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys={})
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
llvm::IntegerType * Int64Ty
llvm::IntegerType * Int32Ty
llvm::PointerType * Int8PtrTy