clang  3.9.0
Macros | Enumerations | Functions | Variables
CGBuiltin.cpp File Reference
#include "CodeGenFunction.h"
#include "CGCXXABI.h"
#include "CGObjCRuntime.h"
#include "CodeGenModule.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/MDBuilder.h"
#include <sstream>
Include dependency graph for CGBuiltin.cpp:

Go to the source code of this file.

Macros

#define NEONMAP0(NameBase)   { #NameBase, NEON::BI__builtin_neon_ ## NameBase, 0, 0, 0 }
 
#define NEONMAP1(NameBase, LLVMIntrinsic, TypeModifier)
 
#define NEONMAP2(NameBase, LLVMIntrinsic, AltLLVMIntrinsic, TypeModifier)
 
#define INTRINSIC_X86_XSAVE_ID(NAME)
 
#define INTRINSIC_WITH_CC(NAME)
 

Enumerations

enum  {
  AddRetType = (1 << 0), Add1ArgType = (1 << 1), Add2ArgTypes = (1 << 2), VectorizeRetType = (1 << 3),
  VectorizeArgTypes = (1 << 4), InventFloatType = (1 << 5), UnsignedAlts = (1 << 6), Use64BitVectors = (1 << 7),
  Use128BitVectors = (1 << 8), Vectorize1ArgType = Add1ArgType | VectorizeArgTypes, VectorRet = AddRetType | VectorizeRetType, VectorRetGetArgs01,
  FpCmpzModifiers
}
 

Functions

static ValueEmitToInt (CodeGenFunction &CGF, llvm::Value *V, QualType T, llvm::IntegerType *IntType)
 Emit the conversions required to turn the given value into an integer of the given size. More...
 
static ValueEmitFromInt (CodeGenFunction &CGF, llvm::Value *V, QualType T, llvm::Type *ResultType)
 
static ValueMakeBinaryAtomicValue (CodeGenFunction &CGF, llvm::AtomicRMWInst::BinOp Kind, const CallExpr *E)
 Utility to insert an atomic instruction based on Instrinsic::ID and the expression node. More...
 
static ValueEmitNontemporalStore (CodeGenFunction &CGF, const CallExpr *E)
 
static ValueEmitNontemporalLoad (CodeGenFunction &CGF, const CallExpr *E)
 
static RValue EmitBinaryAtomic (CodeGenFunction &CGF, llvm::AtomicRMWInst::BinOp Kind, const CallExpr *E)
 
static RValue EmitBinaryAtomicPost (CodeGenFunction &CGF, llvm::AtomicRMWInst::BinOp Kind, const CallExpr *E, Instruction::BinaryOps Op, bool Invert=false)
 Utility to insert an atomic instruction based Instrinsic::ID and the expression node, where the return value is the result of the operation. More...
 
static ValueMakeAtomicCmpXchgValue (CodeGenFunction &CGF, const CallExpr *E, bool ReturnBool)
 Utility to insert an atomic cmpxchg instruction. More...
 
static ValueemitUnaryBuiltin (CodeGenFunction &CGF, const CallExpr *E, unsigned IntrinsicID)
 
static ValueemitBinaryBuiltin (CodeGenFunction &CGF, const CallExpr *E, unsigned IntrinsicID)
 
static ValueemitTernaryBuiltin (CodeGenFunction &CGF, const CallExpr *E, unsigned IntrinsicID)
 
static ValueemitFPIntBuiltin (CodeGenFunction &CGF, const CallExpr *E, unsigned IntrinsicID)
 
static ValueEmitFAbs (CodeGenFunction &CGF, Value *V)
 EmitFAbs - Emit a call to .fabs(). More...
 
static ValueEmitSignBit (CodeGenFunction &CGF, Value *V)
 Emit the computation of the sign bit for a floating point value. More...
 
static RValue emitLibraryCall (CodeGenFunction &CGF, const FunctionDecl *Fn, const CallExpr *E, llvm::Value *calleeValue)
 
static llvm::ValueEmitOverflowIntrinsic (CodeGenFunction &CGF, const llvm::Intrinsic::ID IntrinsicID, llvm::Value *X, llvm::Value *Y, llvm::Value *&Carry)
 Emit a call to llvm. More...
 
static ValueemitRangedBuiltin (CodeGenFunction &CGF, unsigned IntrinsicID, int low, int high)
 
static WidthAndSignedness getIntegerWidthAndSignedness (const clang::ASTContext &context, const clang::QualType Type)
 
static struct WidthAndSignedness EncompassingIntegerType (ArrayRef< struct WidthAndSignedness > Types)
 
static bool areBOSTypesCompatible (int From, int To)
 Checks if using the result of __builtin_object_size(p, From) in place of __builtin_object_size(p, To) is correct. More...
 
static llvm::ValuegetDefaultBuiltinObjectSizeResult (unsigned Type, llvm::IntegerType *ResType)
 
static ValueEmitTargetArchBuiltinExpr (CodeGenFunction *CGF, unsigned BuiltinID, const CallExpr *E, llvm::Triple::ArchType Arch)
 
static llvm::VectorType * GetNeonType (CodeGenFunction *CGF, NeonTypeFlags TypeFlags, bool V1Ty=false)
 
static llvm::VectorType * GetFloatNeonType (CodeGenFunction *CGF, NeonTypeFlags IntTypeFlags)
 
static const NeonIntrinsicInfo * findNeonIntrinsicInMap (ArrayRef< NeonIntrinsicInfo > IntrinsicMap, unsigned BuiltinID, bool &MapProvenSorted)
 
static ValueEmitCommonNeonSISDBuiltinExpr (CodeGenFunction &CGF, const NeonIntrinsicInfo &SISDInfo, SmallVectorImpl< Value * > &Ops, const CallExpr *E)
 
static ValuepackTBLDVectorList (CodeGenFunction &CGF, ArrayRef< Value * > Ops, Value *ExtOp, Value *IndexOp, llvm::Type *ResTy, unsigned IntID, const char *Name)
 
static ValueEmitSpecialRegisterBuiltin (CodeGenFunction &CGF, const CallExpr *E, llvm::Type *RegisterType, llvm::Type *ValueType, bool IsRead, StringRef SysReg="")
 
static bool HasExtraNeonArgument (unsigned BuiltinID)
 Return true if BuiltinID is an overloaded Neon intrinsic with an extra argument that specifies the vector type. More...
 
static ValueEmitAArch64TblBuiltinExpr (CodeGenFunction &CGF, unsigned BuiltinID, const CallExpr *E, SmallVectorImpl< Value * > &Ops)
 
static ValuegetMaskVecValue (CodeGenFunction &CGF, Value *Mask, unsigned NumElts)
 
static ValueEmitX86MaskedStore (CodeGenFunction &CGF, SmallVectorImpl< Value * > &Ops, unsigned Align)
 
static ValueEmitX86MaskedLoad (CodeGenFunction &CGF, SmallVectorImpl< Value * > &Ops, unsigned Align)
 
static ValueEmitX86Select (CodeGenFunction &CGF, Value *Mask, Value *Op0, Value *Op1)
 
static ValueEmitX86MaskedCompare (CodeGenFunction &CGF, unsigned CC, bool Signed, SmallVectorImpl< Value * > &Ops)
 
static ValueEmitSystemZIntrinsicWithCC (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-instruction CC value. More...
 

Variables

static const NeonIntrinsicInfo ARMSIMDIntrinsicMap []
 
static const NeonIntrinsicInfo AArch64SIMDIntrinsicMap []
 
static const NeonIntrinsicInfo AArch64SISDIntrinsicMap []
 
static bool NEONSIMDIntrinsicsProvenSorted = false
 
static bool AArch64SIMDIntrinsicsProvenSorted = false
 
static bool AArch64SISDIntrinsicsProvenSorted = false
 

Macro Definition Documentation

#define INTRINSIC_WITH_CC (   NAME)
Value:
case SystemZ::BI__builtin_##NAME: \
return EmitSystemZIntrinsicWithCC(*this, Intrinsic::NAME, E)
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...
Definition: CGBuiltin.cpp:7702
return(__x >> __y)|(__x<< (32-__y))
detail::InMemoryDirectory::const_iterator E

Referenced by clang::CodeGen::CodeGenFunction::EmitSystemZBuiltinExpr().

#define INTRINSIC_X86_XSAVE_ID (   NAME)
Value:
case X86::BI__builtin_ia32_##NAME: \
ID = Intrinsic::x86_##NAME; \
break
const std::string ID

Referenced by clang::CodeGen::CodeGenFunction::EmitX86BuiltinExpr().

#define NEONMAP0 (   NameBase)    { #NameBase, NEON::BI__builtin_neon_ ## NameBase, 0, 0, 0 }

Definition at line 2664 of file CGBuiltin.cpp.

#define NEONMAP1 (   NameBase,
  LLVMIntrinsic,
  TypeModifier 
)
Value:
{ #NameBase, NEON:: BI__builtin_neon_ ## NameBase, \
Intrinsic::LLVMIntrinsic, 0, TypeModifier }

Definition at line 2667 of file CGBuiltin.cpp.

#define NEONMAP2 (   NameBase,
  LLVMIntrinsic,
  AltLLVMIntrinsic,
  TypeModifier 
)
Value:
{ #NameBase, NEON:: BI__builtin_neon_ ## NameBase, \
Intrinsic::LLVMIntrinsic, Intrinsic::AltLLVMIntrinsic, \
TypeModifier }

Definition at line 2671 of file CGBuiltin.cpp.

Enumeration Type Documentation

anonymous enum
Enumerator
AddRetType 
Add1ArgType 
Add2ArgTypes 
VectorizeRetType 
VectorizeArgTypes 
InventFloatType 
UnsignedAlts 
Use64BitVectors 
Use128BitVectors 
Vectorize1ArgType 
VectorRet 
VectorRetGetArgs01 
FpCmpzModifiers 

Definition at line 2625 of file CGBuiltin.cpp.

Function Documentation

static bool areBOSTypesCompatible ( int  From,
int  To 
)
static

Checks if using the result of __builtin_object_size(p, From) in place of __builtin_object_size(p, To) is correct.

Definition at line 402 of file CGBuiltin.cpp.

static Value* EmitAArch64TblBuiltinExpr ( CodeGenFunction CGF,
unsigned  BuiltinID,
const CallExpr E,
SmallVectorImpl< Value * > &  Ops 
)
static
static RValue EmitBinaryAtomic ( CodeGenFunction CGF,
llvm::AtomicRMWInst::BinOp  Kind,
const CallExpr E 
)
static

Definition at line 136 of file CGBuiltin.cpp.

References clang::CodeGen::RValue::get(), and MakeBinaryAtomicValue().

static RValue EmitBinaryAtomicPost ( CodeGenFunction CGF,
llvm::AtomicRMWInst::BinOp  Kind,
const CallExpr E,
Instruction::BinaryOps  Op,
bool  Invert = false 
)
static
static Value* emitBinaryBuiltin ( CodeGenFunction CGF,
const CallExpr E,
unsigned  IntrinsicID 
)
static
static Value* EmitCommonNeonSISDBuiltinExpr ( CodeGenFunction CGF,
const NeonIntrinsicInfo &  SISDInfo,
SmallVectorImpl< Value * > &  Ops,
const CallExpr E 
)
static
static Value* EmitFAbs ( CodeGenFunction CGF,
Value V 
)
static
static Value* emitFPIntBuiltin ( CodeGenFunction CGF,
const CallExpr E,
unsigned  IntrinsicID 
)
static
static Value* EmitFromInt ( CodeGenFunction CGF,
llvm::Value V,
QualType  T,
llvm::Type *  ResultType 
)
static
static RValue emitLibraryCall ( CodeGenFunction CGF,
const FunctionDecl Fn,
const CallExpr E,
llvm::Value calleeValue 
)
static
static Value* EmitNontemporalLoad ( CodeGenFunction CGF,
const CallExpr E 
)
static
static Value* EmitNontemporalStore ( CodeGenFunction CGF,
const CallExpr E 
)
static
static llvm::Value* EmitOverflowIntrinsic ( CodeGenFunction CGF,
const llvm::Intrinsic::ID  IntrinsicID,
llvm::Value X,
llvm::Value Y,
llvm::Value *&  Carry 
)
static

Emit a call to llvm.

{sadd,uadd,ssub,usub,smul,umul}.with.overflow.* depending on IntrinsicID.

  • CGF The current codegen function.
  • IntrinsicID The ID for the Intrinsic we wish to generate.
  • X The first argument to the llvm.*.with.overflow.*.
  • Y The second argument to the llvm.*.with.overflow.*.
  • Carry The carry returned by the llvm.*.with.overflow.*.
    Returns
    The result (i.e. sum/product) returned by the intrinsic.

Definition at line 320 of file CGBuiltin.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenModule::getIntrinsic(), and X.

static Value* emitRangedBuiltin ( CodeGenFunction CGF,
unsigned  IntrinsicID,
int  low,
int  high 
)
static
static Value* EmitSignBit ( CodeGenFunction CGF,
Value V 
)
static
static Value* EmitSpecialRegisterBuiltin ( CodeGenFunction CGF,
const CallExpr E,
llvm::Type *  RegisterType,
llvm::Type *  ValueType,
bool  IsRead,
StringRef  SysReg = "" 
)
static
static Value* EmitSystemZIntrinsicWithCC ( CodeGenFunction CGF,
unsigned  IntrinsicID,
const CallExpr E 
)
static

Handle a SystemZ function in which the final argument is a pointer to an int that receives the post-instruction CC value.

At the LLVM level this is represented as a function that returns a {result, cc} pair.

Definition at line 7702 of file CGBuiltin.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CGBuilderTy::CreateStore(), clang::CodeGen::CodeGenFunction::EmitPointerWithAlignment(), clang::CodeGen::CodeGenFunction::EmitScalarExpr(), clang::CallExpr::getArg(), clang::CodeGen::CodeGenModule::getIntrinsic(), clang::CallExpr::getNumArgs(), I, and clang::NumArgs.

static Value* EmitTargetArchBuiltinExpr ( CodeGenFunction CGF,
unsigned  BuiltinID,
const CallExpr E,
llvm::Triple::ArchType  Arch 
)
static
static Value* emitTernaryBuiltin ( CodeGenFunction CGF,
const CallExpr E,
unsigned  IntrinsicID 
)
static
static Value* EmitToInt ( CodeGenFunction CGF,
llvm::Value V,
QualType  T,
llvm::IntegerType *  IntType 
)
static

Emit the conversions required to turn the given value into an integer of the given size.

Definition at line 62 of file CGBuiltin.cpp.

References clang::CodeGen::CodeGenFunction::Builder, and clang::CodeGen::CodeGenFunction::EmitToMemory().

Referenced by EmitBinaryAtomicPost(), MakeAtomicCmpXchgValue(), and MakeBinaryAtomicValue().

static Value* emitUnaryBuiltin ( CodeGenFunction CGF,
const CallExpr E,
unsigned  IntrinsicID 
)
static
static Value* EmitX86MaskedCompare ( CodeGenFunction CGF,
unsigned  CC,
bool  Signed,
SmallVectorImpl< Value * > &  Ops 
)
static
static Value* EmitX86MaskedLoad ( CodeGenFunction CGF,
SmallVectorImpl< Value * > &  Ops,
unsigned  Align 
)
static
static Value* EmitX86MaskedStore ( CodeGenFunction CGF,
SmallVectorImpl< Value * > &  Ops,
unsigned  Align 
)
static
static Value* EmitX86Select ( CodeGenFunction CGF,
Value Mask,
Value Op0,
Value Op1 
)
static
static struct WidthAndSignedness EncompassingIntegerType ( ArrayRef< struct WidthAndSignedness >  Types)
static

Definition at line 366 of file CGBuiltin.cpp.

static const NeonIntrinsicInfo* findNeonIntrinsicInMap ( ArrayRef< NeonIntrinsicInfo >  IntrinsicMap,
unsigned  BuiltinID,
bool MapProvenSorted 
)
static
static llvm::Value* getDefaultBuiltinObjectSizeResult ( unsigned  Type,
llvm::IntegerType *  ResType 
)
static

Definition at line 410 of file CGBuiltin.cpp.

static llvm::VectorType* GetFloatNeonType ( CodeGenFunction CGF,
NeonTypeFlags  IntTypeFlags 
)
static
static WidthAndSignedness getIntegerWidthAndSignedness ( const clang::ASTContext context,
const clang::QualType  Type 
)
static
static Value* getMaskVecValue ( CodeGenFunction CGF,
Value Mask,
unsigned  NumElts 
)
static
static llvm::VectorType* GetNeonType ( CodeGenFunction CGF,
NeonTypeFlags  TypeFlags,
bool  V1Ty = false 
)
static
static bool HasExtraNeonArgument ( unsigned  BuiltinID)
static

Return true if BuiltinID is an overloaded Neon intrinsic with an extra argument that specifies the vector type.

Definition at line 3921 of file CGBuiltin.cpp.

Referenced by clang::CodeGen::CodeGenFunction::EmitARMBuiltinExpr().

static Value* MakeAtomicCmpXchgValue ( CodeGenFunction CGF,
const CallExpr E,
bool  ReturnBool 
)
static

Utility to insert an atomic cmpxchg instruction.

Parameters
CGFThe current codegen function.
EBuiltin call expression to convert to cmpxchg. arg0 - address to operate on arg1 - value to compare with arg2 - new value
ReturnBoolSpecifies whether to return success flag of cmpxchg result or the old value.
Returns
result of cmpxchg, according to ReturnBool

Definition at line 191 of file CGBuiltin.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::ConvertType(), clang::CodeGen::CGBuilderTy::CreateBitCast(), EmitFromInt(), clang::CodeGen::CodeGenFunction::EmitScalarExpr(), EmitToInt(), clang::CallExpr::getArg(), clang::CodeGen::CodeGenFunction::getContext(), clang::CodeGen::CodeGenFunction::getLLVMContext(), clang::Expr::getType(), clang::ASTContext::getTypeSize(), and clang::CodeGen::Type.

Referenced by clang::CodeGen::CodeGenFunction::EmitNVPTXBuiltinExpr().

static Value* MakeBinaryAtomicValue ( CodeGenFunction CGF,
llvm::AtomicRMWInst::BinOp  Kind,
const CallExpr E 
)
static
static Value* packTBLDVectorList ( CodeGenFunction CGF,
ArrayRef< Value * >  Ops,
Value ExtOp,
Value IndexOp,
llvm::Type *  ResTy,
unsigned  IntID,
const char *  Name 
)
static

Variable Documentation

const NeonIntrinsicInfo AArch64SIMDIntrinsicMap[]
static

Definition at line 2893 of file CGBuiltin.cpp.

bool AArch64SIMDIntrinsicsProvenSorted = false
static

Definition at line 3209 of file CGBuiltin.cpp.

const NeonIntrinsicInfo AArch64SISDIntrinsicMap[]
static

Definition at line 3008 of file CGBuiltin.cpp.

bool AArch64SISDIntrinsicsProvenSorted = false
static

Definition at line 3210 of file CGBuiltin.cpp.

const NeonIntrinsicInfo ARMSIMDIntrinsicMap[]
static

Definition at line 2676 of file CGBuiltin.cpp.

bool NEONSIMDIntrinsicsProvenSorted = false
static

Definition at line 3207 of file CGBuiltin.cpp.