42 bool doInitialization(
Module &M)
override;
44 const char *getPassName()
const override {
45 return "SI Type Rewriter";
56 bool SITypeRewriter::doInitialization(
Module &M) {
63 bool SITypeRewriter::runOnFunction(
Function &
F) {
80 void SITypeRewriter::visitLoadInst(
LoadInst &
I) {
85 if (ElemTy == v16i8) {
86 Value *BitCast = Builder.CreateBitCast(Ptr,
91 for (
unsigned i = 0, e = MD.
size(); i != e; ++i) {
94 Value *BitCastLoad = Builder.CreateBitCast(Load, I.
getType());
100 void SITypeRewriter::visitCallInst(
CallInst &I) {
105 bool NeedToReplace =
false;
111 Args.
push_back(Builder.CreateBitCast(Arg, v4i32));
113 NeedToReplace =
true;
114 Name = Name +
".v4i32";
120 std::string TypeName =
"i32";
124 std::string VecTypeName =
"v1" + TypeName;
125 Name = Name.replace(Name.find(VecTypeName), VecTypeName.length(), TypeName);
126 NeedToReplace =
true;
133 if (!NeedToReplace) {
136 Function *NewF = Mod->getFunction(Name);
145 void SITypeRewriter::visitBitCast(
BitCastInst &I) {
152 if (Op->getSrcTy() == v4i32) {
160 return new SITypeRewriter();
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
iplist< Instruction >::iterator eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing basic block and deletes it...
void push_back(const T &Elt)
Base class for instruction visitors.
A Module instance is used to store all the information related to an LLVM module. ...
CallInst - This class represents a function call, abstracting a target machine's calling convention...
static PointerType * get(Type *ElementType, unsigned AddressSpace)
PointerType::get - This constructs a pointer to an object of the specified type in a numbered address...
Externally visible function.
Type * getReturnType() const
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
LoadInst - an instruction for reading from memory.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Type * getPointerElementType() const
StringRef getName() const
Return a constant reference to the value's name.
unsigned getNumArgOperands() const
getNumArgOperands - Return the number of call arguments.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Type * getVectorElementType() const
FunctionPass * createSITypeRewriter()
This class represents a no-op cast from one type to another.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
FunctionType::get - This static method is the primary way of constructing a FunctionType.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
InsertElementInst - This instruction inserts a single (scalar) element into a VectorType value...
The instances of the Type class are immutable: once they are created, they are never changed...
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
getAllMetadataOtherThanDebugLoc - This does the same thing as getAllMetadata, except that it filters ...
bool isVectorTy() const
isVectorTy - True if this is an instance of VectorType.
FunctionPass class - This class is used to implement most global optimizations.
Value * getOperand(unsigned i) const
Value * getPointerOperand()
LLVMContext & getContext() const
All values hold a context through their type.
void setMetadata(unsigned KindID, MDNode *Node)
setMetadata - Set the metadata of the specified kind to the specified node.
unsigned getVectorNumElements() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Type * getType() const
All values are typed, get the type of this value.
Type * getDestTy() const
Return the destination type, as a convenience.
Function * getCalledFunction() const
getCalledFunction - Return the function called, or null if this is an indirect function invocation...
AttributeSet getAttributes() const
Return the attribute list for this Function.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
static IntegerType * getInt32Ty(LLVMContext &C)
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
void setAttributes(AttributeSet attrs)
Set the attribute list for this Function.
StringRef getValueAsString() const
Return the attribute's value as a string.
LLVM Value Representation.
static VectorType * get(Type *ElementType, unsigned NumElements)
VectorType::get - This static method is the primary way to construct an VectorType.
StringRef - Represent a constant reference to a string, i.e.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
static IntegerType * getInt8Ty(LLVMContext &C)
LLVMContext & getContext() const
Get the global data context.