InstructionsSoa Class Reference

Collaboration diagram for InstructionsSoa:

Collaboration graph
[legend]

Public Member Functions

 InstructionsSoa (llvm::Module *mod, llvm::Function *func, llvm::BasicBlock *block, StorageSoa *storage)
std::vector< llvm::Value * > abs (const std::vector< llvm::Value * > in1)
std::vector< llvm::Value * > arl (const std::vector< llvm::Value * > in)
std::vector< llvm::Value * > add (const std::vector< llvm::Value * > in1, const std::vector< llvm::Value * > in2)
std::vector< llvm::Value * > dp3 (const std::vector< llvm::Value * > in1, const std::vector< llvm::Value * > in2)
std::vector< llvm::Value * > dp4 (const std::vector< llvm::Value * > in1, const std::vector< llvm::Value * > in2)
std::vector< llvm::Value * > lit (const std::vector< llvm::Value * > in)
std::vector< llvm::Value * > madd (const std::vector< llvm::Value * > in1, const std::vector< llvm::Value * > in2, const std::vector< llvm::Value * > in3)
std::vector< llvm::Value * > max (const std::vector< llvm::Value * > in1, const std::vector< llvm::Value * > in2)
std::vector< llvm::Value * > min (const std::vector< llvm::Value * > in1, const std::vector< llvm::Value * > in2)
std::vector< llvm::Value * > mul (const std::vector< llvm::Value * > in1, const std::vector< llvm::Value * > in2)
std::vector< llvm::Value * > pow (const std::vector< llvm::Value * > in1, const std::vector< llvm::Value * > in2)
std::vector< llvm::Value * > rsq (const std::vector< llvm::Value * > in1)
std::vector< llvm::Value * > slt (const std::vector< llvm::Value * > in1, const std::vector< llvm::Value * > in2)
std::vector< llvm::Value * > sub (const std::vector< llvm::Value * > in1, const std::vector< llvm::Value * > in2)
void end ()
std::vector< llvm::Value * > extractVector (llvm::Value *vector)

Private Member Functions

const char * name (const char *prefix) const
llvm::Value * vectorFromVals (llvm::Value *x, llvm::Value *y, llvm::Value *z, llvm::Value *w)
void createFunctionMap ()
void createBuiltins ()
void createDependencies ()
llvm::Function * function (int)
llvm::Module * currentModule () const
llvm::Value * allocaTemp ()
std::vector< llvm::Value * > allocaToResult (llvm::Value *allocaPtr)
std::vector< llvm::Value * > callBuiltin (llvm::Function *func, const std::vector< llvm::Value * > in1)
std::vector< llvm::Value * > callBuiltin (llvm::Function *func, const std::vector< llvm::Value * > in1, const std::vector< llvm::Value * > in2)
std::vector< llvm::Value * > callBuiltin (llvm::Function *func, const std::vector< llvm::Value * > in1, const std::vector< llvm::Value * > in2, const std::vector< llvm::Value * > in3)
void injectFunction (llvm::Function *originalFunc, int op=TGSI_OPCODE_LAST)

Private Attributes

llvm::IRBuilder m_builder
StorageSoam_storage
std::map< int, std::string > m_functionsMap
std::map< int, llvm::Function * > m_functions
llvm::Module * m_builtins
std::map< std::string,
std::vector< std::string > > 
m_builtinDependencies
int m_idx
char m_name [32]

Detailed Description

Definition at line 45 of file instructionssoa.h.


Constructor & Destructor Documentation

InstructionsSoa::InstructionsSoa ( llvm::Module *  mod,
llvm::Function *  func,
llvm::BasicBlock *  block,
StorageSoa storage 
)

Definition at line 58 of file instructionssoa.cpp.

References createBuiltins(), and createFunctionMap().

00060    : m_builder(block),
00061      m_storage(storage),
00062      m_idx(0)
00063 {
00064    createFunctionMap();
00065    createBuiltins();
00066 }


Member Function Documentation

std::vector< llvm::Value * > InstructionsSoa::abs ( const std::vector< llvm::Value * >  in1  ) 

Definition at line 271 of file instructionssoa.cpp.

References callBuiltin(), function(), and TGSI_OPCODE_ABS.

00272 {
00273    llvm::Function *func = function(TGSI_OPCODE_ABS);
00274    return callBuiltin(func, in1);
00275 }

std::vector< llvm::Value * > InstructionsSoa::arl ( const std::vector< llvm::Value * >  in  ) 

Definition at line 93 of file instructionssoa.cpp.

References StorageSoa::constantInt(), m_builder, m_storage, and name().

00094 {
00095    std::vector<llvm::Value*> res(4);
00096 
00097    //Extract x's
00098    llvm::Value *x1 = m_builder.CreateExtractElement(in[0],
00099                                                     m_storage->constantInt(0),
00100                                                     name("extractX"));
00101    //cast it to an unsigned int
00102    x1 = m_builder.CreateFPToUI(x1, IntegerType::get(32), name("x1IntCast"));
00103 
00104    res[0] = x1;//vectorFromVals(x1, x2, x3, x4);
00105    //only x is valid. the others shouldn't be necessary
00106    /*
00107    res[1] = Constant::getNullValue(m_floatVecType);
00108    res[2] = Constant::getNullValue(m_floatVecType);
00109    res[3] = Constant::getNullValue(m_floatVecType);
00110    */
00111 
00112    return res;
00113 }

std::vector< llvm::Value * > InstructionsSoa::add ( const std::vector< llvm::Value * >  in1,
const std::vector< llvm::Value * >  in2 
)

Definition at line 116 of file instructionssoa.cpp.

References m_builder, and name().

00118 {
00119    std::vector<llvm::Value*> res(4);
00120 
00121    res[0] = m_builder.CreateAdd(in1[0], in2[0], name("addx"));
00122    res[1] = m_builder.CreateAdd(in1[1], in2[1], name("addy"));
00123    res[2] = m_builder.CreateAdd(in1[2], in2[2], name("addz"));
00124    res[3] = m_builder.CreateAdd(in1[3], in2[3], name("addw"));
00125 
00126    return res;
00127 }

std::vector< llvm::Value * > InstructionsSoa::dp3 ( const std::vector< llvm::Value * >  in1,
const std::vector< llvm::Value * >  in2 
)

Definition at line 277 of file instructionssoa.cpp.

References callBuiltin(), function(), and TGSI_OPCODE_DP3.

00279 {
00280    llvm::Function *func = function(TGSI_OPCODE_DP3);
00281    return callBuiltin(func, in1, in2);
00282 }

std::vector< llvm::Value * > InstructionsSoa::dp4 ( const std::vector< llvm::Value * >  in1,
const std::vector< llvm::Value * >  in2 
)

Definition at line 338 of file instructionssoa.cpp.

References callBuiltin(), function(), and TGSI_OPCODE_DP4.

00340 {
00341    llvm::Function *func = function(TGSI_OPCODE_DP4);
00342    return callBuiltin(func, in1, in2);
00343 }

std::vector< llvm::Value * > InstructionsSoa::lit ( const std::vector< llvm::Value * >  in  ) 

Definition at line 508 of file instructionssoa.cpp.

References callBuiltin(), function(), and TGSI_OPCODE_LIT.

00509 {
00510    llvm::Function *func = function(TGSI_OPCODE_LIT);
00511    return callBuiltin(func, in);
00512 }

std::vector< llvm::Value * > InstructionsSoa::madd ( const std::vector< llvm::Value * >  in1,
const std::vector< llvm::Value * >  in2,
const std::vector< llvm::Value * >  in3 
)

Definition at line 147 of file instructionssoa.cpp.

References mul().

00150 {
00151    std::vector<llvm::Value*> res = mul(in1, in2);
00152    return add(res, in3);
00153 }

std::vector< llvm::Value * > InstructionsSoa::max ( const std::vector< llvm::Value * >  in1,
const std::vector< llvm::Value * >  in2 
)

Definition at line 426 of file instructionssoa.cpp.

References callBuiltin(), function(), and TGSI_OPCODE_MAX.

00428 {
00429    llvm::Function *func = function(TGSI_OPCODE_MAX);
00430    return callBuiltin(func, in1, in2);
00431 }

std::vector< llvm::Value * > InstructionsSoa::min ( const std::vector< llvm::Value * >  in1,
const std::vector< llvm::Value * >  in2 
)

Definition at line 418 of file instructionssoa.cpp.

References callBuiltin(), function(), and TGSI_OPCODE_MIN.

00420 {
00421    llvm::Function *func = function(TGSI_OPCODE_MIN);
00422    return callBuiltin(func, in1, in2);
00423 }

std::vector< llvm::Value * > InstructionsSoa::mul ( const std::vector< llvm::Value * >  in1,
const std::vector< llvm::Value * >  in2 
)

Definition at line 129 of file instructionssoa.cpp.

References m_builder, and name().

00131 {
00132    std::vector<llvm::Value*> res(4);
00133 
00134    res[0] = m_builder.CreateMul(in1[0], in2[0], name("mulx"));
00135    res[1] = m_builder.CreateMul(in1[1], in2[1], name("muly"));
00136    res[2] = m_builder.CreateMul(in1[2], in2[2], name("mulz"));
00137    res[3] = m_builder.CreateMul(in1[3], in2[3], name("mulw"));
00138 
00139    return res;
00140 }

std::vector< llvm::Value * > InstructionsSoa::pow ( const std::vector< llvm::Value * >  in1,
const std::vector< llvm::Value * >  in2 
)

Definition at line 411 of file instructionssoa.cpp.

References callBuiltin(), function(), and TGSI_OPCODE_POWER.

00413 {
00414    llvm::Function *func = function(TGSI_OPCODE_POWER);
00415    return callBuiltin(func, in1, in2);
00416 }

std::vector< llvm::Value * > InstructionsSoa::rsq ( const std::vector< llvm::Value * >  in1  ) 

Definition at line 514 of file instructionssoa.cpp.

References callBuiltin(), function(), and TGSI_OPCODE_RSQ.

00515 {
00516    llvm::Function *func = function(TGSI_OPCODE_RSQ);
00517    return callBuiltin(func, in);
00518 }

std::vector< llvm::Value * > InstructionsSoa::slt ( const std::vector< llvm::Value * >  in1,
const std::vector< llvm::Value * >  in2 
)

Definition at line 285 of file instructionssoa.cpp.

References callBuiltin(), function(), and TGSI_OPCODE_SLT.

00287 {
00288    llvm::Function *func = function(TGSI_OPCODE_SLT);
00289    return callBuiltin(func, in1, in2);
00290 }

std::vector< llvm::Value * > InstructionsSoa::sub ( const std::vector< llvm::Value * >  in1,
const std::vector< llvm::Value * >  in2 
)

Definition at line 495 of file instructionssoa.cpp.

References m_builder, and name().

00497 {
00498    std::vector<llvm::Value*> res(4);
00499 
00500    res[0] = m_builder.CreateSub(in1[0], in2[0], name("subx"));
00501    res[1] = m_builder.CreateSub(in1[1], in2[1], name("suby"));
00502    res[2] = m_builder.CreateSub(in1[2], in2[2], name("subz"));
00503    res[3] = m_builder.CreateSub(in1[3], in2[3], name("subw"));
00504 
00505    return res;
00506 }

void InstructionsSoa::end (  ) 

Definition at line 142 of file instructionssoa.cpp.

References m_builder.

00143 {
00144    m_builder.CreateRetVoid();
00145 }

std::vector< llvm::Value * > InstructionsSoa::extractVector ( llvm::Value *  vector  ) 

Definition at line 155 of file instructionssoa.cpp.

References StorageSoa::constantInt(), m_builder, m_storage, and name().

00156 {
00157    std::vector<llvm::Value*> res(4);
00158    res[0] = m_builder.CreateExtractElement(vector,
00159                                            m_storage->constantInt(0),
00160                                            name("extract1X"));
00161    res[1] = m_builder.CreateExtractElement(vector,
00162                                            m_storage->constantInt(1),
00163                                            name("extract2X"));
00164    res[2] = m_builder.CreateExtractElement(vector,
00165                                            m_storage->constantInt(2),
00166                                            name("extract3X"));
00167    res[3] = m_builder.CreateExtractElement(vector,
00168                                            m_storage->constantInt(3),
00169                                            name("extract4X"));
00170 
00171    return res;
00172 }

const char * InstructionsSoa::name ( const char *  prefix  )  const [private]

Definition at line 68 of file instructionssoa.cpp.

References m_idx, and m_name.

00069 {
00070    ++m_idx;
00071    snprintf(m_name, 32, "%s%d", prefix, m_idx);
00072    return m_name;
00073 }

llvm::Value * InstructionsSoa::vectorFromVals ( llvm::Value *  x,
llvm::Value *  y,
llvm::Value *  z,
llvm::Value *  w 
) [private]

Definition at line 75 of file instructionssoa.cpp.

References StorageSoa::constantInt(), m_builder, m_storage, and name().

00077 {
00078    VectorType  *vectorType = VectorType::get(Type::FloatTy, 4);
00079    Constant *constVector = Constant::getNullValue(vectorType);
00080    Value *res = m_builder.CreateInsertElement(constVector, x,
00081                                               m_storage->constantInt(0),
00082                                               name("vecx"));
00083    res = m_builder.CreateInsertElement(res, y, m_storage->constantInt(1),
00084                                name("vecxy"));
00085    res = m_builder.CreateInsertElement(res, z, m_storage->constantInt(2),
00086                                name("vecxyz"));
00087    if (w)
00088       res = m_builder.CreateInsertElement(res, w, m_storage->constantInt(3),
00089                                           name("vecxyzw"));
00090    return res;
00091 }

void InstructionsSoa::createFunctionMap (  )  [private]

Definition at line 174 of file instructionssoa.cpp.

References m_functionsMap, TGSI_OPCODE_ABS, TGSI_OPCODE_DP3, TGSI_OPCODE_DP4, TGSI_OPCODE_LIT, TGSI_OPCODE_MAX, TGSI_OPCODE_MIN, TGSI_OPCODE_POWER, TGSI_OPCODE_RSQ, and TGSI_OPCODE_SLT.

00175 {
00176    m_functionsMap[TGSI_OPCODE_ABS]   = "abs";
00177    m_functionsMap[TGSI_OPCODE_DP3]   = "dp3";
00178    m_functionsMap[TGSI_OPCODE_DP4]   = "dp4";
00179    m_functionsMap[TGSI_OPCODE_MIN]   = "min";
00180    m_functionsMap[TGSI_OPCODE_MAX]   = "max";
00181    m_functionsMap[TGSI_OPCODE_POWER] = "pow";
00182    m_functionsMap[TGSI_OPCODE_LIT]   = "lit";
00183    m_functionsMap[TGSI_OPCODE_RSQ]   = "rsq";
00184    m_functionsMap[TGSI_OPCODE_SLT]   = "slt";
00185 }

void InstructionsSoa::createBuiltins (  )  [private]

Definition at line 259 of file instructionssoa.cpp.

References assert, createDependencies(), Elements, and m_builtins.

00260 {
00261    MemoryBuffer *buffer = MemoryBuffer::getMemBuffer(
00262       (const char*)&soabuiltins_data[0],
00263       (const char*)&soabuiltins_data[Elements(soabuiltins_data)]);
00264    m_builtins = ParseBitcodeFile(buffer);
00265    std::cout<<"Builtins created at "<<m_builtins<<std::endl;
00266    assert(m_builtins);
00267    createDependencies();
00268 }

void InstructionsSoa::createDependencies (  )  [private]

Definition at line 187 of file instructionssoa.cpp.

References m_builtinDependencies.

00188 {
00189    {
00190       std::vector<std::string> powDeps(2);
00191       powDeps[0] = "powf";
00192       powDeps[1] = "powvec";
00193       m_builtinDependencies["pow"] = powDeps;
00194    }
00195    {
00196       std::vector<std::string> absDeps(2);
00197       absDeps[0] = "fabsf";
00198       absDeps[1] = "absvec";
00199       m_builtinDependencies["abs"] = absDeps;
00200    }
00201    {
00202       std::vector<std::string> maxDeps(1);
00203       maxDeps[0] = "maxvec";
00204       m_builtinDependencies["max"] = maxDeps;
00205    }
00206    {
00207       std::vector<std::string> minDeps(1);
00208       minDeps[0] = "minvec";
00209       m_builtinDependencies["min"] = minDeps;
00210    }
00211    {
00212       std::vector<std::string> litDeps(4);
00213       litDeps[0] = "minvec";
00214       litDeps[1] = "maxvec";
00215       litDeps[2] = "powf";
00216       litDeps[3] = "powvec";
00217       m_builtinDependencies["lit"] = litDeps;
00218    }
00219    {
00220       std::vector<std::string> rsqDeps(4);
00221       rsqDeps[0] = "sqrtf";
00222       rsqDeps[1] = "sqrtvec";
00223       rsqDeps[2] = "fabsf";
00224       rsqDeps[3] = "absvec";
00225       m_builtinDependencies["rsq"] = rsqDeps;
00226    }
00227 }

llvm::Function * InstructionsSoa::function ( int  op  )  [private]

Definition at line 229 of file instructionssoa.cpp.

References injectFunction(), m_builtinDependencies, m_builtins, m_functions, m_functionsMap, and name().

00230 {
00231     if (m_functions.find(op) != m_functions.end())
00232        return m_functions[op];
00233 
00234     std::string name = m_functionsMap[op];
00235 
00236     std::cout <<"For op = "<<op<<", func is '"<<name<<"'"<<std::endl;
00237 
00238     std::vector<std::string> deps = m_builtinDependencies[name];
00239     for (unsigned int i = 0; i < deps.size(); ++i) {
00240        llvm::Function *func = m_builtins->getFunction(deps[i]);
00241        std::cout <<"\tinjecting dep = '"<<func->getName()<<"'"<<std::endl;
00242        injectFunction(func);
00243     }
00244 
00245     llvm::Function *originalFunc = m_builtins->getFunction(name);
00246     injectFunction(originalFunc, op);
00247     return m_functions[op];
00248 }

llvm::Module * InstructionsSoa::currentModule (  )  const [private]

Definition at line 250 of file instructionssoa.cpp.

References block(), and m_builder.

00251 {
00252    BasicBlock *block = m_builder.GetInsertBlock();
00253    if (!block || !block->getParent())
00254       return 0;
00255 
00256    return block->getParent()->getParent();
00257 }

llvm::Value * InstructionsSoa::allocaTemp (  )  [private]

Definition at line 292 of file instructionssoa.cpp.

References StorageSoa::constantInt(), m_builder, m_storage, and name().

00293 {
00294    VectorType *vector   = VectorType::get(Type::FloatTy, 4);
00295    ArrayType  *vecArray = ArrayType::get(vector, 4);
00296    AllocaInst *alloca = new AllocaInst(vecArray, name("tmpRes"),
00297                                        m_builder.GetInsertBlock());
00298 
00299    std::vector<Value*> indices;
00300    indices.push_back(m_storage->constantInt(0));
00301    indices.push_back(m_storage->constantInt(0));
00302    GetElementPtrInst *getElem = GetElementPtrInst::Create(alloca,
00303                                                           indices.begin(),
00304                                                           indices.end(),
00305                                                           name("allocaPtr"),
00306                                                           m_builder.GetInsertBlock());
00307    return getElem;
00308 }

std::vector< llvm::Value * > InstructionsSoa::allocaToResult ( llvm::Value *  allocaPtr  )  [private]

Definition at line 310 of file instructionssoa.cpp.

References StorageSoa::constantInt(), m_builder, m_storage, and name().

00311 {
00312    GetElementPtrInst *xElemPtr =  GetElementPtrInst::Create(allocaPtr,
00313                                                             m_storage->constantInt(0),
00314                                                             name("xPtr"),
00315                                                             m_builder.GetInsertBlock());
00316    GetElementPtrInst *yElemPtr =  GetElementPtrInst::Create(allocaPtr,
00317                                                             m_storage->constantInt(1),
00318                                                             name("yPtr"),
00319                                                             m_builder.GetInsertBlock());
00320    GetElementPtrInst *zElemPtr =  GetElementPtrInst::Create(allocaPtr,
00321                                                             m_storage->constantInt(2),
00322                                                             name("zPtr"),
00323                                                             m_builder.GetInsertBlock());
00324    GetElementPtrInst *wElemPtr =  GetElementPtrInst::Create(allocaPtr,
00325                                                             m_storage->constantInt(3),
00326                                                             name("wPtr"),
00327                                                             m_builder.GetInsertBlock());
00328 
00329    std::vector<llvm::Value*> res(4);
00330    res[0] = new LoadInst(xElemPtr, name("xRes"), false, m_builder.GetInsertBlock());
00331    res[1] = new LoadInst(yElemPtr, name("yRes"), false, m_builder.GetInsertBlock());
00332    res[2] = new LoadInst(zElemPtr, name("zRes"), false, m_builder.GetInsertBlock());
00333    res[3] = new LoadInst(wElemPtr, name("wRes"), false, m_builder.GetInsertBlock());
00334 
00335    return res;
00336 }

std::vector< Value * > InstructionsSoa::callBuiltin ( llvm::Function *  func,
const std::vector< llvm::Value * >  in1 
) [private]

Definition at line 345 of file instructionssoa.cpp.

References allocaTemp(), allocaToResult(), C, and m_builder.

00346 {
00347    std::vector<Value*> params;
00348 
00349    llvm::Value *allocaPtr = allocaTemp();
00350    params.push_back(allocaPtr);
00351    params.push_back(in1[0]);
00352    params.push_back(in1[1]);
00353    params.push_back(in1[2]);
00354    params.push_back(in1[3]);
00355    CallInst *call = m_builder.CreateCall(func, params.begin(), params.end());
00356    call->setCallingConv(CallingConv::C);
00357    call->setTailCall(false);
00358 
00359    return allocaToResult(allocaPtr);
00360 }

std::vector< Value * > InstructionsSoa::callBuiltin ( llvm::Function *  func,
const std::vector< llvm::Value * >  in1,
const std::vector< llvm::Value * >  in2 
) [private]

Definition at line 362 of file instructionssoa.cpp.

References allocaTemp(), allocaToResult(), C, and m_builder.

00364 {
00365    std::vector<Value*> params;
00366 
00367    llvm::Value *allocaPtr = allocaTemp();
00368    params.push_back(allocaPtr);
00369    params.push_back(in1[0]);
00370    params.push_back(in1[1]);
00371    params.push_back(in1[2]);
00372    params.push_back(in1[3]);
00373    params.push_back(in2[0]);
00374    params.push_back(in2[1]);
00375    params.push_back(in2[2]);
00376    params.push_back(in2[3]);
00377    CallInst *call = m_builder.CreateCall(func, params.begin(), params.end());
00378    call->setCallingConv(CallingConv::C);
00379    call->setTailCall(false);
00380 
00381    return allocaToResult(allocaPtr);
00382 }

std::vector< Value * > InstructionsSoa::callBuiltin ( llvm::Function *  func,
const std::vector< llvm::Value * >  in1,
const std::vector< llvm::Value * >  in2,
const std::vector< llvm::Value * >  in3 
) [private]

Definition at line 384 of file instructionssoa.cpp.

References allocaTemp(), allocaToResult(), C, and m_builder.

00387 {
00388    std::vector<Value*> params;
00389 
00390    llvm::Value *allocaPtr = allocaTemp();
00391    params.push_back(allocaPtr);
00392    params.push_back(in1[0]);
00393    params.push_back(in1[1]);
00394    params.push_back(in1[2]);
00395    params.push_back(in1[3]);
00396    params.push_back(in2[0]);
00397    params.push_back(in2[1]);
00398    params.push_back(in2[2]);
00399    params.push_back(in2[3]);
00400    params.push_back(in3[0]);
00401    params.push_back(in3[1]);
00402    params.push_back(in3[2]);
00403    params.push_back(in3[3]);
00404    CallInst *call = m_builder.CreateCall(func, params.begin(), params.end());
00405    call->setCallingConv(CallingConv::C);
00406    call->setTailCall(false);
00407 
00408    return allocaToResult(allocaPtr);
00409 }

void InstructionsSoa::injectFunction ( llvm::Function *  originalFunc,
int  op = TGSI_OPCODE_LAST 
) [private]

Definition at line 451 of file instructionssoa.cpp.

References assert, C, checkFunction(), currentModule(), m_builtins, m_functions, and TGSI_OPCODE_LAST.

00452 {
00453    assert(originalFunc);
00454    std::cout << "injecting function originalFunc " <<originalFunc->getName() <<std::endl;
00455    if (op != TGSI_OPCODE_LAST) {
00456       /* in this case it's possible the function has been already
00457        * injected as part of the dependency chain, which gets
00458        * injected below */
00459       llvm::Function *func = currentModule()->getFunction(originalFunc->getName());
00460       if (func) {
00461          m_functions[op] = func;
00462          return;
00463       }
00464    }
00465    llvm::Function *func = 0;
00466    if (originalFunc->isDeclaration()) {
00467       func = Function::Create(originalFunc->getFunctionType(), GlobalValue::ExternalLinkage,
00468                               originalFunc->getName(), currentModule());
00469       func->setCallingConv(CallingConv::C);
00470       const AttrListPtr pal;
00471       func->setAttributes(pal);
00472       currentModule()->dump();
00473    } else {
00474       DenseMap<const Value*, Value *> val;
00475       val[m_builtins->getFunction("fabsf")] = currentModule()->getFunction("fabsf");
00476       val[m_builtins->getFunction("powf")] = currentModule()->getFunction("powf");
00477       val[m_builtins->getFunction("sqrtf")] = currentModule()->getFunction("sqrtf");
00478       func = CloneFunction(originalFunc, val);
00479 #if 0
00480       std::cout <<" replacing "<<m_builtins->getFunction("powf")
00481                 <<", with " <<currentModule()->getFunction("powf")<<std::endl;
00482       std::cout<<"1111-------------------------------"<<std::endl;
00483       checkFunction(originalFunc);
00484       std::cout<<"2222-------------------------------"<<std::endl;
00485       checkFunction(func);
00486       std::cout <<"XXXX = " <<val[m_builtins->getFunction("powf")]<<std::endl;
00487 #endif
00488       currentModule()->getFunctionList().push_back(func);
00489    }
00490    if (op != TGSI_OPCODE_LAST) {
00491       m_functions[op] = func;
00492    }
00493 }


Field Documentation

llvm::IRBuilder InstructionsSoa::m_builder [private]

Definition at line 101 of file instructionssoa.h.

StorageSoa* InstructionsSoa::m_storage [private]

Definition at line 102 of file instructionssoa.h.

std::map<int, std::string> InstructionsSoa::m_functionsMap [private]

Definition at line 104 of file instructionssoa.h.

std::map<int, llvm::Function*> InstructionsSoa::m_functions [private]

Definition at line 105 of file instructionssoa.h.

llvm::Module* InstructionsSoa::m_builtins [private]

Definition at line 106 of file instructionssoa.h.

std::map<std::string, std::vector<std::string> > InstructionsSoa::m_builtinDependencies [private]

Definition at line 107 of file instructionssoa.h.

int InstructionsSoa::m_idx [mutable, private]

Definition at line 110 of file instructionssoa.h.

char InstructionsSoa::m_name[32] [mutable, private]

Definition at line 111 of file instructionssoa.h.


The documentation for this class was generated from the following files:
Generated on Tue Sep 29 06:26:02 2009 for Gallium3D by  doxygen 1.5.4