Use llvm 2.3 (2.2 won't work because of a lot of problems, e.g.
authorZack Rusin <zack@tungstengraphics.com>
Mon, 21 Apr 2008 19:15:31 +0000 (15:15 -0400)
committerZack Rusin <zack@tungstengraphics.com>
Mon, 21 Apr 2008 19:18:13 +0000 (15:18 -0400)
lack of constant vectors handling in execution engine)

src/gallium/auxiliary/gallivm/Makefile
src/gallium/auxiliary/gallivm/instructions.cpp
src/gallium/auxiliary/gallivm/instructions.h
src/gallium/auxiliary/gallivm/instructionssoa.cpp
src/gallium/auxiliary/gallivm/instructionssoa.h
src/gallium/auxiliary/gallivm/storage.cpp
src/gallium/auxiliary/gallivm/storagesoa.cpp
src/gallium/auxiliary/gallivm/tgsitollvm.cpp

index 6bfd187fb315ca1f2eff87c05548a05437159526..c3f7bfba93be5ed8ebc33f55d4194fd734665058 100644 (file)
@@ -65,14 +65,14 @@ depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(INC_SOURCES)
 
 
 gallivm_builtins.cpp: llvm_builtins.c
-       clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp.bin
-       (echo "static const unsigned char llvm_builtins_data[] = {"; od -txC temp.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/};/") >$@
-       rm temp.bin
+       clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp1.bin
+       (echo "static const unsigned char llvm_builtins_data[] = {"; od -txC temp1.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/};/") >$@
+       rm temp1.bin
 
 gallivmsoabuiltins.cpp: soabuiltins.c
-       clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp.bin
-       (echo "static const unsigned char soabuiltins_data[] = {"; od -txC temp.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/};/") >$@
-       rm temp.bin
+       clang --emit-llvm < $< |llvm-as|opt -std-compile-opts > temp2.bin
+       (echo "static const unsigned char soabuiltins_data[] = {"; od -txC temp2.bin | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$$d" | sed -e"\$$s/,$$/};/") >$@
+       rm temp2.bin
 
 # Emacs tags
 tags:
index b35d6790f790c2d8c2ec8d972e0ad2f97364c5a0..95a670edafc65ea6bea24f0c6f5e107e29d39b6d 100644 (file)
@@ -139,12 +139,12 @@ llvm::Value *Instructions::callFSqrt(llvm::Value *val)
       // predeclare the intrinsic
       std::vector<const Type*> fsqrtArgs;
       fsqrtArgs.push_back(Type::FloatTy);
-      ParamAttrsList *fsqrtPal = 0;
+      PAListPtr fsqrtPal;
       FunctionType* fsqrtType = FunctionType::get(
          /*Result=*/Type::FloatTy,
          /*Params=*/fsqrtArgs,
          /*isVarArg=*/false);
-      m_llvmFSqrt = new Function(
+      m_llvmFSqrt = Function::Create(
          /*Type=*/fsqrtType,
          /*Linkage=*/GlobalValue::ExternalLinkage,
          /*Name=*/"llvm.sqrt.f32", m_mod);
@@ -196,12 +196,12 @@ llvm::Value *Instructions::callFAbs(llvm::Value *val)
       // predeclare the intrinsic
       std::vector<const Type*> fabsArgs;
       fabsArgs.push_back(Type::FloatTy);
-      ParamAttrsList *fabsPal = 0;
+      PAListPtr fabsPal;
       FunctionType* fabsType = FunctionType::get(
          /*Result=*/Type::FloatTy,
          /*Params=*/fabsArgs,
          /*isVarArg=*/false);
-      m_llvmFAbs = new Function(
+      m_llvmFAbs = Function::Create(
          /*Type=*/fabsType,
          /*Linkage=*/GlobalValue::ExternalLinkage,
          /*Name=*/"fabs", m_mod);
@@ -239,12 +239,12 @@ llvm::Value * Instructions::callPow(llvm::Value *val1, llvm::Value *val2)
       std::vector<const Type*> powArgs;
       powArgs.push_back(Type::FloatTy);
       powArgs.push_back(Type::FloatTy);
-      ParamAttrsList *powPal = 0;
+      PAListPtr powPal;
       FunctionType* powType = FunctionType::get(
          /*Result=*/Type::FloatTy,
          /*Params=*/powArgs,
          /*isVarArg=*/false);
-      m_llvmPow = new Function(
+      m_llvmPow = Function::Create(
          /*Type=*/powType,
          /*Linkage=*/GlobalValue::ExternalLinkage,
          /*Name=*/"llvm.pow.f32", m_mod);
@@ -338,12 +338,12 @@ llvm::Value * Instructions::callFloor(llvm::Value *val)
       // predeclare the intrinsic
       std::vector<const Type*> floorArgs;
       floorArgs.push_back(Type::FloatTy);
-      ParamAttrsList *floorPal = 0;
+      PAListPtr floorPal;
       FunctionType* floorType = FunctionType::get(
          /*Result=*/Type::FloatTy,
          /*Params=*/floorArgs,
          /*isVarArg=*/false);
-      m_llvmFloor = new Function(
+      m_llvmFloor = Function::Create(
          /*Type=*/floorType,
          /*Linkage=*/GlobalValue::ExternalLinkage,
          /*Name=*/"floorf", m_mod);
@@ -381,12 +381,12 @@ llvm::Value * Instructions::callFLog(llvm::Value *val)
       // predeclare the intrinsic
       std::vector<const Type*> flogArgs;
       flogArgs.push_back(Type::FloatTy);
-      ParamAttrsList *flogPal = 0;
+      PAListPtr flogPal;
       FunctionType* flogType = FunctionType::get(
          /*Result=*/Type::FloatTy,
          /*Params=*/flogArgs,
          /*isVarArg=*/false);
-      m_llvmFlog = new Function(
+      m_llvmFlog = Function::Create(
          /*Type=*/flogType,
          /*Linkage=*/GlobalValue::ExternalLinkage,
          /*Name=*/"logf", m_mod);
@@ -509,12 +509,12 @@ void Instructions::printVector(llvm::Value *val)
 llvm::Function * Instructions::declarePrintf()
 {
    std::vector<const Type*> args;
-   ParamAttrsList *params = 0;
+   PAListPtr params;
    FunctionType* funcTy = FunctionType::get(
       /*Result=*/IntegerType::get(32),
       /*Params=*/args,
       /*isVarArg=*/true);
-   Function* func_printf = new Function(
+   Function* func_printf = Function::Create(
       /*Type=*/funcTy,
       /*Linkage=*/GlobalValue::ExternalLinkage,
       /*Name=*/"printf", m_mod);
@@ -638,8 +638,8 @@ llvm::Value * Instructions::abs(llvm::Value *in)
 
 void Instructions::ifop(llvm::Value *in)
 {
-   BasicBlock *ifthen = new BasicBlock(name("ifthen"), m_func,0);
-   BasicBlock *ifend = new BasicBlock(name("ifthenend"), m_func,0);
+   BasicBlock *ifthen = BasicBlock::Create(name("ifthen"), m_func,0);
+   BasicBlock *ifend = BasicBlock::Create(name("ifthenend"), m_func,0);
 
    //BasicBlock *yblock = new BasicBlock(name("yblock"), m_func,0);
    //BasicBlock *zblock = new BasicBlock(name("zblock"), m_func,0);
@@ -665,7 +665,7 @@ llvm::BasicBlock * Instructions::currentBlock() const
 void Instructions::elseop()
 {
    assert(!m_ifStack.empty());
-   BasicBlock *ifend = new BasicBlock(name("ifend"), m_func,0);
+   BasicBlock *ifend = BasicBlock::Create(name("ifend"), m_func,0);
    m_builder.CreateBr(ifend);
    m_builder.SetInsertPoint(m_ifStack.top());
    currentBlock()->setName(name("ifelse"));
@@ -692,8 +692,8 @@ llvm::Value * Instructions::lerp(llvm::Value *in1, llvm::Value *in2,
 
 void Instructions::beginLoop()
 {
-   BasicBlock *begin = new BasicBlock(name("loop"), m_func,0);
-   BasicBlock *end = new BasicBlock(name("endloop"), m_func,0);
+   BasicBlock *begin = BasicBlock::Create(name("loop"), m_func,0);
+   BasicBlock *end = BasicBlock::Create(name("endloop"), m_func,0);
 
    m_builder.CreateBr(begin);
    Loop loop;
@@ -716,7 +716,7 @@ void Instructions::endLoop()
 void Instructions::brk()
 {
    assert(!m_loopStack.empty());
-   BasicBlock *unr = new BasicBlock(name("unreachable"), m_func,0);
+   BasicBlock *unr = BasicBlock::Create(name("unreachable"), m_func,0);
    m_builder.CreateBr(m_loopStack.top().end);
    m_builder.SetInsertPoint(unr);
 }
@@ -765,13 +765,13 @@ llvm::Function * Instructions::declareFunc(int label)
    args.push_back(vecPtr);
    args.push_back(vecPtr);
    args.push_back(vecPtr);
-   ParamAttrsList *params = 0;
+   PAListPtr params;
    FunctionType *funcType = FunctionType::get(
       /*Result=*/Type::VoidTy,
       /*Params=*/args,
       /*isVarArg=*/false);
    std::string name = createFuncName(label);
-   Function *func = new Function(
+   Function *func = Function::Create(
       /*Type=*/funcType,
       /*Linkage=*/GlobalValue::ExternalLinkage,
       /*Name=*/name.c_str(), m_mod);
@@ -789,7 +789,7 @@ void Instructions::bgnSub(unsigned label)
    ptr_INPUT->setName("INPUT");
    m_storage->pushArguments(ptr_INPUT);
 
-   llvm::BasicBlock *entry = new BasicBlock("entry", func, 0);
+   llvm::BasicBlock *entry = BasicBlock::Create("entry", func, 0);
 
    m_func = func;
    m_builder.SetInsertPoint(entry);
index 9ebc17dd8ecfd6fca46bba05e31d7f3de4569f20..19ca84ddc6851b2482a2251eadee04b08d2d7aa6 100644 (file)
@@ -36,7 +36,7 @@
 #include <llvm/BasicBlock.h>
 #include <llvm/Module.h>
 #include <llvm/Value.h>
-#include <llvm/Support/LLVMBuilder.h>
+#include <llvm/Support/IRBuilder.h>
 
 #include <map>
 #include <stack>
@@ -125,7 +125,7 @@ private:
    llvm::Module             *m_mod;
    llvm::Function           *m_func;
    char                      m_name[32];
-   llvm::LLVMFoldingBuilder  m_builder;
+   llvm::IRBuilder           m_builder;
    int                       m_idx;
 
    llvm::VectorType *m_floatVecType;
index 3c16a3692dba5317ddec036677a3781f497902e6..f0122802db952c473de2ac5e7c28e6259d12f46b 100644 (file)
@@ -38,6 +38,7 @@
 #include <llvm/Instructions.h>
 #include <llvm/Transforms/Utils/Cloning.h>
 #include <llvm/ParameterAttributes.h>
+//#include <llvm/ParamAttrsList.h>
 #include <llvm/Support/MemoryBuffer.h>
 #include <llvm/Bitcode/ReaderWriter.h>
 
@@ -237,32 +238,32 @@ llvm::Value * InstructionsSoa::allocaTemp()
    std::vector<Value*> indices;
    indices.push_back(m_storage->constantInt(0));
    indices.push_back(m_storage->constantInt(0));
-   GetElementPtrInst *getElem = new GetElementPtrInst(alloca,
-                                                      indices.begin(),
-                                                      indices.end(),
-                                                      name("allocaPtr"),
-                                                      m_builder.GetInsertBlock());
+   GetElementPtrInst *getElem = GetElementPtrInst::Create(alloca,
+                                                          indices.begin(),
+                                                          indices.end(),
+                                                          name("allocaPtr"),
+                                                          m_builder.GetInsertBlock());
    return getElem;
 }
 
 std::vector<llvm::Value*> InstructionsSoa::allocaToResult(llvm::Value *allocaPtr)
 {
-   GetElementPtrInst *xElemPtr =  new GetElementPtrInst(allocaPtr,
-                                                        m_storage->constantInt(0),
-                                                        name("xPtr"),
-                                                        m_builder.GetInsertBlock());
-   GetElementPtrInst *yElemPtr =  new GetElementPtrInst(allocaPtr,
-                                                        m_storage->constantInt(1),
-                                                        name("yPtr"),
-                                                        m_builder.GetInsertBlock());
-   GetElementPtrInst *zElemPtr =  new GetElementPtrInst(allocaPtr,
-                                                        m_storage->constantInt(2),
-                                                        name("zPtr"),
-                                                        m_builder.GetInsertBlock());
-   GetElementPtrInst *wElemPtr =  new GetElementPtrInst(allocaPtr,
-                                                        m_storage->constantInt(3),
-                                                        name("wPtr"),
-                                                        m_builder.GetInsertBlock());
+   GetElementPtrInst *xElemPtr =  GetElementPtrInst::Create(allocaPtr,
+                                                            m_storage->constantInt(0),
+                                                            name("xPtr"),
+                                                            m_builder.GetInsertBlock());
+   GetElementPtrInst *yElemPtr =  GetElementPtrInst::Create(allocaPtr,
+                                                            m_storage->constantInt(1),
+                                                            name("yPtr"),
+                                                            m_builder.GetInsertBlock());
+   GetElementPtrInst *zElemPtr =  GetElementPtrInst::Create(allocaPtr,
+                                                            m_storage->constantInt(2),
+                                                            name("zPtr"),
+                                                            m_builder.GetInsertBlock());
+   GetElementPtrInst *wElemPtr =  GetElementPtrInst::Create(allocaPtr,
+                                                            m_storage->constantInt(3),
+                                                            name("wPtr"),
+                                                            m_builder.GetInsertBlock());
 
    std::vector<llvm::Value*> res(4);
    res[0] = new LoadInst(xElemPtr, name("xRes"), false, m_builder.GetInsertBlock());
@@ -388,10 +389,10 @@ void InstructionsSoa::injectFunction(llvm::Function *originalFunc, int op)
    llvm::Function *func = 0;
    if (originalFunc->isDeclaration()) {
       std::cout << "function decleration" <<std::endl;
-      func = new Function(originalFunc->getFunctionType(), GlobalValue::ExternalLinkage,
-                          originalFunc->getName(), currentModule());
+      func = Function::Create(originalFunc->getFunctionType(), GlobalValue::ExternalLinkage,
+                              originalFunc->getName(), currentModule());
       func->setCallingConv(CallingConv::C);
-      const ParamAttrsList *pal = 0;
+      const PAListPtr pal;
       func->setParamAttrs(pal);
       currentModule()->dump();
    } else {
index b9104ea286d0c61b8b54c8f0a840ef5568f79ac0..060ee72f2e8b3d6fb3d271106d5f918189c17c8b 100644 (file)
@@ -29,7 +29,7 @@
 #define INSTRUCTIONSSOA_H
 
 #include <pipe/p_shader_tokens.h>
-#include <llvm/Support/LLVMBuilder.h>
+#include <llvm/Support/IRBuilder.h>
 
 #include <map>
 #include <vector>
@@ -87,7 +87,7 @@ private:
                                          const std::vector<llvm::Value*> in3);
    void injectFunction(llvm::Function *originalFunc, int op = TGSI_OPCODE_LAST);
 private:
-   llvm::LLVMFoldingBuilder  m_builder;
+   llvm::IRBuilder  m_builder;
    StorageSoa *m_storage;
 
    std::map<int, std::string> m_functionsMap;
index c4326de8c53a7de92b7f539ae8420c2d1374cc06..9d9fd12360418dcfd84102b11a819bd4c9a7c9a9 100644 (file)
@@ -186,26 +186,26 @@ llvm::Value *Storage::maskWrite(llvm::Value *src, int mask, llvm::Value *templ)
    if ((mask & TGSI_WRITEMASK_X)) {
       llvm::Value *x = new ExtractElementInst(src, unsigned(0),
                                               name("x"), m_block);
-      dst = new InsertElementInst(dst, x, unsigned(0),
-                                  name("dstx"), m_block);
+      dst = InsertElementInst::Create(dst, x, unsigned(0),
+                                      name("dstx"), m_block);
    }
    if ((mask & TGSI_WRITEMASK_Y)) {
       llvm::Value *y = new ExtractElementInst(src, unsigned(1),
                                               name("y"), m_block);
-      dst = new InsertElementInst(dst, y, unsigned(1),
-                                  name("dsty"), m_block);
+      dst = InsertElementInst::Create(dst, y, unsigned(1),
+                                      name("dsty"), m_block);
    }
    if ((mask & TGSI_WRITEMASK_Z)) {
       llvm::Value *z = new ExtractElementInst(src, unsigned(2),
                                               name("z"), m_block);
-      dst = new InsertElementInst(dst, z, unsigned(2),
-                                  name("dstz"), m_block);
+      dst = InsertElementInst::Create(dst, z, unsigned(2),
+                                      name("dstz"), m_block);
    }
    if ((mask & TGSI_WRITEMASK_W)) {
       llvm::Value *w = new ExtractElementInst(src, unsigned(3),
                                               name("w"), m_block);
-      dst = new InsertElementInst(dst, w, unsigned(3),
-                                  name("dstw"), m_block);
+      dst = InsertElementInst::Create(dst, w, unsigned(3),
+                                      name("dstw"), m_block);
    }
    return dst;
 }
@@ -308,11 +308,11 @@ llvm::Value * Storage::elemPtr(Args arg)
    std::vector<Value*> indices;
    indices.push_back(constantInt(0));
    indices.push_back(constantInt(static_cast<int>(arg)));
-   GetElementPtrInst *getElem = new GetElementPtrInst(m_INPUT,
-                                                      indices.begin(),
-                                                      indices.end(),
-                                                      name("input_ptr"),
-                                                      m_block);
+   GetElementPtrInst *getElem = GetElementPtrInst::Create(m_INPUT,
+                                                          indices.begin(),
+                                                          indices.end(),
+                                                          name("input_ptr"),
+                                                          m_block);
    return new LoadInst(getElem, name("input_field"), false, m_block);
 }
 
@@ -322,7 +322,7 @@ llvm::Value * Storage::elemIdx(llvm::Value *ptr, int idx,
    GetElementPtrInst *getElem = 0;
 
    if (indIdx) {
-      getElem = new GetElementPtrInst(ptr,
+      getElem = GetElementPtrInst::Create(ptr,
                                       BinaryOperator::create(Instruction::Add,
                                                              indIdx,
                                                              constantInt(idx),
@@ -331,7 +331,7 @@ llvm::Value * Storage::elemIdx(llvm::Value *ptr, int idx,
                                       name("field"),
                                       m_block);
    } else {
-      getElem = new GetElementPtrInst(ptr,
+      getElem = GetElementPtrInst::Create(ptr,
                                       constantInt(idx),
                                       name("field"),
                                       m_block);
@@ -350,7 +350,7 @@ void Storage::setKilElement(llvm::Value *val)
    std::vector<Value*> indices;
    indices.push_back(constantInt(0));
    indices.push_back(constantInt(static_cast<int>(KilArg)));
-   GetElementPtrInst *elem = new GetElementPtrInst(m_INPUT,
+   GetElementPtrInst *elem = GetElementPtrInst::Create(m_INPUT,
                                                    indices.begin(),
                                                    indices.end(),
                                                    name("kil_ptr"),
index bb6fe3d7e1176f414bd89f3476ca550d4e053dde..0e6e68c9d709d4d0c0885f6cdd113c62933d2f5c 100644 (file)
@@ -207,11 +207,11 @@ llvm::Value * StorageSoa::elementPointer(llvm::Value *ptr, llvm::Value *index,
    indices.push_back(index);
    indices.push_back(constantInt(channel));
 
-   GetElementPtrInst *getElem = new GetElementPtrInst(ptr,
-                                                      indices.begin(),
-                                                      indices.end(),
-                                                      name("ptr"),
-                                                      m_block);
+   GetElementPtrInst *getElem = GetElementPtrInst::Create(ptr,
+                                                          indices.begin(),
+                                                          indices.end(),
+                                                          name("ptr"),
+                                                          m_block);
    return getElem;
 }
 
index ab9e7a06fbaeb1adf5e55c4213ebae49ecf89207..ab8c851f148ce67e167c193d4651e66264f239f9 100644 (file)
@@ -1014,7 +1014,7 @@ tgsi_to_llvm(struct gallivm_ir *ir, const struct tgsi_token *tokens)
    Value *ptr_INPUT = args++;
    ptr_INPUT->setName("input");
 
-   BasicBlock *label_entry = new BasicBlock("entry", shader, 0);
+   BasicBlock *label_entry = BasicBlock::Create("entry", shader, 0);
 
    tgsi_parse_init(&parse, tokens);
 
@@ -1085,7 +1085,7 @@ llvm::Module * tgsi_to_llvmir(struct gallivm_ir *ir,
    Value *temps = args++;
    temps->setName("temps");
 
-   BasicBlock *label_entry = new BasicBlock("entry", shader, 0);
+   BasicBlock *label_entry = BasicBlock::Create("entry", shader, 0);
 
    tgsi_parse_init(&parse, tokens);