43 bool doInitialization(
Module &M)
override;
45 StringRef getPassName()
const override {
return "SI Type Rewriter"; }
55 bool SITypeRewriter::doInitialization(
Module &M) {
62 bool SITypeRewriter::runOnFunction(
Function &
F) {
72 void SITypeRewriter::visitLoadInst(
LoadInst &
I) {
77 if (ElemTy == v16i8) {
78 Value *BitCast = Builder.CreateBitCast(Ptr,
83 for (
unsigned i = 0, e = MD.
size();
i != e; ++
i) {
86 Value *BitCastLoad = Builder.CreateBitCast(Load, I.
getType());
92 void SITypeRewriter::visitCallInst(
CallInst &I) {
97 bool NeedToReplace =
false;
106 Args.
push_back(Builder.CreateBitCast(Arg, v4i32));
108 NeedToReplace =
true;
109 Name = Name +
".v4i32";
115 std::string TypeName =
"i32";
119 std::string VecTypeName =
"v1" + TypeName;
120 Name = Name.replace(Name.find(VecTypeName), VecTypeName.length(), TypeName);
121 NeedToReplace =
true;
128 if (!NeedToReplace) {
131 Function *NewF = Mod->getFunction(Name);
140 void SITypeRewriter::visitBitCast(
BitCastInst &I) {
147 if (
Op->getSrcTy() == v4i32) {
155 return new SITypeRewriter();
SymbolTableList< Instruction >::iterator 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. ...
This class represents a function call, abstracting a target machine's calling convention.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
Externally visible function.
Type * getReturnType() const
Returns the type of the ret val.
An instruction for reading from memory.
Type * getPointerElementType() const
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
StringRef getName() const
Return a constant reference to the value's name.
unsigned getNumArgOperands() const
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)
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.
This instruction inserts a single (scalar) element into a VectorType value.
bool isShader(CallingConv::ID cc)
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
This does the same thing as getAllMetadata, except that it filters out the debug location.
bool isVectorTy() const
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)
Set the metadata of the specified kind to the specified node.
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
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.
unsigned getVectorNumElements() const
void setAttributes(AttributeSet Attrs)
Set the attribute list for this Function.
static IntegerType * getInt32Ty(LLVMContext &C)
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
LLVM Value Representation.
static VectorType * get(Type *ElementType, unsigned NumElements)
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)
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static IntegerType * getInt8Ty(LLVMContext &C)
LLVMContext & getContext() const
Get the global data context.