43 virtual bool doInitialization(
Module &M);
45 virtual const char *getPassName()
const {
46 return "SI Type Rewriter";
57 bool SITypeRewriter::doInitialization(
Module &M) {
64 bool SITypeRewriter::runOnFunction(
Function &
F) {
82 void SITypeRewriter::visitLoadInst(
LoadInst &
I) {
87 if (ElemTy == v16i8) {
92 for (
unsigned i = 0, e = MD.
size(); i != e; ++i) {
95 Value *BitCastLoad = Builder.CreateBitCast(Load, I.
getType());
101 void SITypeRewriter::visitCallInst(
CallInst &I) {
105 bool NeedToReplace =
false;
111 Args.
push_back(Builder.CreateBitCast(Arg, i128));
113 NeedToReplace =
true;
114 Name = Name +
".i128";
120 std::string TypeName =
"i32";
125 std::string VecTypeName =
"v1" + TypeName;
126 Name = Name.replace(Name.find(VecTypeName), VecTypeName.length(), TypeName);
127 NeedToReplace =
true;
134 if (!NeedToReplace) {
137 Function *NewF = Mod->getFunction(Name);
146 void SITypeRewriter::visitBitCast(
BitCastInst &I) {
153 if (Op->getSrcTy() == i128) {
161 return new SITypeRewriter();
void push_back(const T &Elt)
Base class for instruction visitors.
The main container class for the LLVM Intermediate Representation.
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Externally visible function.
std::string str() const
str - Get the contents as an std::string.
Type * getReturnType() const
Type * getPointerElementType() const
StringRef getName() const
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
unsigned getNumArgOperands() const
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
ID
LLVM Calling Convention Representation.
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)
void replaceAllUsesWith(Value *V)
Value * getOperand(unsigned i) const
Value * getPointerOperand()
enable_if_c< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
LLVMContext & getContext() const
All values hold a context through their type.
void setMetadata(unsigned KindID, MDNode *Node)
unsigned getVectorNumElements() const
Type * getDestTy() const
Return the destination type, as a convenience.
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Function * getCalledFunction() const
AttributeSet getAttributes() const
Return the attribute list for this Function.
Value * getArgOperand(unsigned i) const
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.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
static PointerType * getIntNPtrTy(LLVMContext &C, unsigned N, unsigned AS=0)
StringRef getValueAsString() const
Return the attribute's value as a string. This requires the attribute to be a string attribute...
LLVM Value Representation.
static VectorType * get(Type *ElementType, unsigned NumElements)
static IntegerType * getInt8Ty(LLVMContext &C)
LLVMContext & getContext() const
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=0)