Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
Classes | Namespaces | Macros | Enumerations | Functions
cbackend.cpp File Reference
#include "ispc.h"
#include "module.h"
#include "util.h"
#include <math.h>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "llvmutil.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/CodeGen/IntrinsicLowering.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/TypeFinder.h"
#include "llvm/IR/Verifier.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/FileSystem.h"
#include <llvm/IR/IRPrintingPasses.h>
#include "llvm/Transforms/Scalar.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Target/TargetMachine.h"
#include <llvm/Support/ToolOutputFile.h>
#include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/Utils/BasicBlockUtils.h>
#include <algorithm>

Go to the source code of this file.

Classes

class  constant_scanner::constant_iterator
 
class  SmearCleanupPass
 
class  AndCmpCleanupPass
 
class  MaskOpsCleanupPass
 

Namespaces

 constant_scanner
 

Macros

#define HAVE_PRINTF_A   1
 
#define ENABLE_CBE_PRINTF_A   1
 
#define GET_GCC_BUILTIN_NAME
 
#define Intrinsic   llvm::Intrinsic
 
#define GET_GCC_BUILTIN_NAME
 
#define Intrinsic   llvm::Intrinsic
 

Enumerations

enum  SpecialGlobalClass { NotSpecial = 0, GlobalCtors, GlobalDtors, NotPrinted }
 

Functions

constant_iterator constant_scanner::constant_begin (const llvm::Function *F)
 
constant_iterator constant_scanner::constant_end (const llvm::Function *F)
 
static void findUsedArrayAndLongIntTypes (const llvm::Module *m, std::vector< llvm::ArrayType *> &t, std::vector< llvm::IntegerType *> &i, std::vector< bool > &IsVolatile, std::vector< int > &Alignment)
 
static bool is_vec16_i64_ty (llvm::Type *Ty)
 
static std::string CBEMangle (const std::string &S)
 
static std::string ftostr (const llvm::APFloat &V)
 
static bool isFPCSafeToPrint (const llvm::ConstantFP *CFP)
 
static const char * lGetTypedFunc (const char *base, llvm::Type *matchType, int width)
 
static void generateCompilerSpecificCode (llvm::formatted_raw_ostream &Out, const llvm::DataLayout *TD)
 
static void FindStaticTors (llvm::GlobalVariable *GV, std::set< llvm::Function *> &StaticTors)
 
static SpecialGlobalClass getGlobalVariableClass (const llvm::GlobalVariable *GV)
 
static void PrintEscapedString (const char *Str, unsigned Length, llvm::raw_ostream &Out)
 
static void PrintEscapedString (const std::string &Str, llvm::raw_ostream &Out)
 
static bool isFPIntBitCast (const llvm::Instruction &I)
 
static const char * lPredicateToString (llvm::CmpInst::Predicate p)
 
static const char * lTypeToSuffix (llvm::Type *t)
 
static const char * getFloatBitCastField (llvm::Type *Ty)
 
static void printLimitValue (llvm::IntegerType &Ty, bool isSigned, bool isMax, llvm::raw_ostream &Out)
 
static bool isSupportedIntegerSize (llvm::IntegerType &T)
 
static bool lIsAllTrue (llvm::Value *v)
 
bool WriteCXXFile (llvm::Module *module, const char *fn, int vectorWidth, const char *includeName)
 

Macro Definition Documentation

◆ ENABLE_CBE_PRINTF_A

#define ENABLE_CBE_PRINTF_A   1

Definition at line 27 of file cbackend.cpp.

◆ GET_GCC_BUILTIN_NAME [1/2]

#define GET_GCC_BUILTIN_NAME

◆ GET_GCC_BUILTIN_NAME [2/2]

#define GET_GCC_BUILTIN_NAME

◆ HAVE_PRINTF_A

#define HAVE_PRINTF_A   1

Definition at line 26 of file cbackend.cpp.

◆ Intrinsic [1/2]

#define Intrinsic   llvm::Intrinsic

◆ Intrinsic [2/2]

#define Intrinsic   llvm::Intrinsic

Enumeration Type Documentation

◆ SpecialGlobalClass

Enumerator
NotSpecial 
GlobalCtors 
GlobalDtors 
NotPrinted 

Definition at line 2227 of file cbackend.cpp.

Function Documentation

◆ CBEMangle()

static std::string CBEMangle ( const std::string &  S)
static

Definition at line 619 of file cbackend.cpp.

References Assert, LLVMTypes::Int8Type, and is_vec16_i64_ty().

Referenced by lGetTypedFunc().

◆ FindStaticTors()

static void FindStaticTors ( llvm::GlobalVariable *  GV,
std::set< llvm::Function *> &  StaticTors 
)
static

FindStaticTors - Given a static ctor/dtor list, unpack its contents into the StaticTors set.

Definition at line 2206 of file cbackend.cpp.

Referenced by PrintEscapedString().

◆ findUsedArrayAndLongIntTypes()

static void findUsedArrayAndLongIntTypes ( const llvm::Module *  m,
std::vector< llvm::ArrayType *> &  t,
std::vector< llvm::IntegerType *> &  i,
std::vector< bool > &  IsVolatile,
std::vector< int > &  Alignment 
)
static

Definition at line 309 of file cbackend.cpp.

Referenced by PrintEscapedString().

◆ ftostr()

static std::string ftostr ( const llvm::APFloat &  V)
inlinestatic

Definition at line 1023 of file cbackend.cpp.

Referenced by isFPCSafeToPrint(), and lGetTypedFunc().

◆ generateCompilerSpecificCode()

static void generateCompilerSpecificCode ( llvm::formatted_raw_ostream &  Out,
const llvm::DataLayout *  TD 
)
static

Definition at line 2088 of file cbackend.cpp.

Referenced by PrintEscapedString().

◆ getFloatBitCastField()

static const char* getFloatBitCastField ( llvm::Type *  Ty)
static

Definition at line 3770 of file cbackend.cpp.

References isFPIntBitCast().

◆ getGlobalVariableClass()

static SpecialGlobalClass getGlobalVariableClass ( const llvm::GlobalVariable *  GV)
static

getGlobalVariableClass - If this is a global that is specially recognized by LLVM, return a code that indicates how we should handle it.

Definition at line 2231 of file cbackend.cpp.

References GlobalCtors, GlobalDtors, NotPrinted, and NotSpecial.

Referenced by PrintEscapedString().

◆ is_vec16_i64_ty()

static bool is_vec16_i64_ty ( llvm::Type *  Ty)
static

Definition at line 315 of file cbackend.cpp.

Referenced by CBEMangle(), and PrintEscapedString().

◆ isFPCSafeToPrint()

static bool isFPCSafeToPrint ( const llvm::ConstantFP *  CFP)
static

Definition at line 1043 of file cbackend.cpp.

References Assert, and ftostr().

Referenced by PrintEscapedString().

◆ isFPIntBitCast()

static bool isFPIntBitCast ( const llvm::Instruction &  I)
inlinestatic

Definition at line 3066 of file cbackend.cpp.

References Assert, and LLVMVectorValuesAllEqual().

Referenced by getFloatBitCastField().

◆ isSupportedIntegerSize()

static bool isSupportedIntegerSize ( llvm::IntegerType &  T)
static

Definition at line 3873 of file cbackend.cpp.

References Assert, and printLimitValue().

◆ lGetTypedFunc()

static const char* lGetTypedFunc ( const char *  base,
llvm::Type *  matchType,
int  width 
)
static

Construct the name of a function with the given base and returning a vector of a given type, of the specified idth. For example, if base is "foo" and matchType is i32 and width is 16, this will return the string "__foo_i32<__vec16_i32>".

Definition at line 1209 of file cbackend.cpp.

References Assert, CBEMangle(), and ftostr().

◆ lIsAllTrue()

static bool lIsAllTrue ( llvm::Value *  v)
static

Returns true if the given value is a compile-time constant vector of i1s with all elements 'true'.

Definition at line 5139 of file cbackend.cpp.

◆ lPredicateToString()

static const char* lPredicateToString ( llvm::CmpInst::Predicate  p)
static

Definition at line 3537 of file cbackend.cpp.

Referenced by lTypeToSuffix().

◆ lTypeToSuffix()

static const char* lTypeToSuffix ( llvm::Type *  t)
static

Definition at line 3595 of file cbackend.cpp.

References Assert, and lPredicateToString().

◆ PrintEscapedString() [1/2]

static void PrintEscapedString ( const char *  Str,
unsigned  Length,
llvm::raw_ostream &  Out 
)
static

Definition at line 2251 of file cbackend.cpp.

Referenced by PrintEscapedString().

◆ PrintEscapedString() [2/2]

static void PrintEscapedString ( const std::string &  Str,
llvm::raw_ostream &  Out 
)
static

◆ printLimitValue()

static void printLimitValue ( llvm::IntegerType &  Ty,
bool  isSigned,
bool  isMax,
llvm::raw_ostream &  Out 
)
static

Definition at line 3849 of file cbackend.cpp.

Referenced by isSupportedIntegerSize().

◆ WriteCXXFile()

bool WriteCXXFile ( llvm::Module *  module,
const char *  fn,
int  vectorWidth,
const char *  includeName 
)

Definition at line 5237 of file cbackend.cpp.

Referenced by Module::writeOutput().