clang 24.0.0git
CGBuiltin.h
Go to the documentation of this file.
1//===------ CGBuiltin.h - Emit LLVM Code for builtins ---------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H
10#define LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H
11
12#include "CodeGenFunction.h"
13
14// Emit a simple intrinsic that has N scalar arguments and a return type
15// matching the argument type. It is assumed that only the first argument is
16// overloaded.
17template <unsigned N>
19 const clang::CallExpr *E,
20 unsigned IntrinsicID,
21 llvm::StringRef Name = "") {
22 static_assert(N, "expect non-empty argument");
24 for (unsigned I = 0; I < N; ++I)
25 Args.push_back(CGF.EmitScalarExpr(E->getArg(I)));
26 llvm::Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Args[0]->getType());
27 return CGF.Builder.CreateCall(F, Args, Name);
28}
29
30// Fills in the trailing parameters of an intrinsic that the builtin does not
31// expose, using the values declared via ImmArg<..., DefaultValue<...>>.
33 llvm::Function *F);
34
36 const clang::CallExpr *E,
37 unsigned IntrinsicID,
38 unsigned ConstrainedIntrinsicID);
39
40llvm::Value *EmitToInt(clang::CodeGen::CodeGenFunction &CGF, llvm::Value *V,
41 clang::QualType T, llvm::IntegerType *IntType);
42
43llvm::Value *EmitFromInt(clang::CodeGen::CodeGenFunction &CGF, llvm::Value *V,
44 clang::QualType T, llvm::Type *ResultType);
45
47 const clang::CallExpr *E);
48
49llvm::Value *
51 llvm::AtomicRMWInst::BinOp Kind, const clang::CallExpr *E,
52 llvm::AtomicOrdering Ordering =
53 llvm::AtomicOrdering::SequentiallyConsistent,
54 llvm::SyncScope::ID SSID = llvm::SyncScope::System);
55
57 const llvm::Intrinsic::ID IntrinsicID,
58 llvm::Value *X,
59 llvm::Value *Y,
60 llvm::Value *&Carry);
61
62llvm::Value *
64 const clang::CallExpr *E, bool ReturnBool,
65 llvm::AtomicOrdering SuccessOrdering,
66 llvm::AtomicOrdering FailureOrdering,
67 llvm::SyncScope::ID SSID = llvm::SyncScope::System);
68
69#endif
#define V(N, I)
llvm::Value * emitBuiltinWithOneOverloadedType(clang::CodeGen::CodeGenFunction &CGF, const clang::CallExpr *E, unsigned IntrinsicID, llvm::StringRef Name="")
Definition CGBuiltin.h:18
llvm::Value * MakeBinaryAtomicValue(clang::CodeGen::CodeGenFunction &CGF, llvm::AtomicRMWInst::BinOp Kind, const clang::CallExpr *E, llvm::AtomicOrdering Ordering=llvm::AtomicOrdering::SequentiallyConsistent, llvm::SyncScope::ID SSID=llvm::SyncScope::System)
clang::CodeGen::Address CheckAtomicAlignment(clang::CodeGen::CodeGenFunction &CGF, const clang::CallExpr *E)
llvm::Value * MakeAtomicCmpXchgValue(clang::CodeGen::CodeGenFunction &CGF, const clang::CallExpr *E, bool ReturnBool, llvm::AtomicOrdering SuccessOrdering, llvm::AtomicOrdering FailureOrdering, llvm::SyncScope::ID SSID=llvm::SyncScope::System)
Utility to insert an atomic cmpxchg instruction.
llvm::Value * EmitToInt(clang::CodeGen::CodeGenFunction &CGF, llvm::Value *V, clang::QualType T, llvm::IntegerType *IntType)
Emit the conversions required to turn the given value into an integer of the given size.
llvm::Value * EmitOverflowIntrinsic(clang::CodeGen::CodeGenFunction &CGF, const llvm::Intrinsic::ID IntrinsicID, llvm::Value *X, llvm::Value *Y, llvm::Value *&Carry)
llvm::Value * EmitFromInt(clang::CodeGen::CodeGenFunction &CGF, llvm::Value *V, clang::QualType T, llvm::Type *ResultType)
llvm::Value * emitUnaryMaybeConstrainedFPBuiltin(clang::CodeGen::CodeGenFunction &CGF, const clang::CallExpr *E, unsigned IntrinsicID, unsigned ConstrainedIntrinsicID)
void appendDefaultIntrinsicArgs(llvm::SmallVectorImpl< llvm::Value * > &Args, llvm::Function *F)
TokenType getType() const
Returns the token's type, e.g.
#define X(type, name)
Definition Value.h:97
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:3012
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition Expr.h:3216
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
Definition Address.h:128
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type,...
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys={})
A (possibly-)qualified type.
Definition TypeBase.h:938