Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ WARNLEVEL=-Wall -Wno-non-virtual-dtor
OPTLEVEL=-O0 -g

BUILDFLAGS=-D_DEBUG
BUILDFLAGS=

# compiler
CXX=g++ -std=c++11
CXXFLAGS=-fno-rtti -c -fPIC -Iinclude $(LLVM_CXXFLAGS) $(WARNLEVEL) $(OPTLEVEL) $(BUILDFLAGS)
LDFLAGS=-fPIC -Iinclude $(LLVM_LDFLAGS) $(LLVM_LIBS)
LDFLAGS=-fPIC -Iinclude $(LLVM_LDFLAGS) $(LLVM_LIBS) -lpthread -lcurses


# Feature support
Expand Down
2 changes: 1 addition & 1 deletion include/axtor/ast/ASTNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace axtor
void setNode(int idx, ControlNode * node);
NodeType getType() const;

llvm::TerminatorInst * getTerminator() const;
llvm::Instruction* getTerminator() const;

NodeVector::const_iterator begin() const;
NodeVector::const_iterator end() const;
Expand Down
2 changes: 1 addition & 1 deletion include/axtor/pass/Serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <axtor/config.h>

#include <llvm/Pass.h>
#include <llvm/PassSupport.h>
// #include <llvm/PassSupport.h>

#include <axtor/backend/AxtorBackend.h>
#include <axtor/CommonTypes.h>
Expand Down
2 changes: 1 addition & 1 deletion include/axtor/pass/SimpleUnswitchPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <llvm/Pass.h>
#include <llvm/Analysis/Passes.h>

#include <llvm/IR/BasicBlock.h>

namespace axtor {
/*
Expand Down
4 changes: 2 additions & 2 deletions include/axtor/util/llvmShortCuts.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

#include <axtor/CommonTypes.h>

#include <llvm/IR/InstrTypes.h>
#include <llvm/IR/Type.h>
#include <llvm/IR/Function.h>
//#include <llvm/TypeSymbolTable.h>

#include <axtor/util/SharedContext.h>
#include <axtor/util/ExtractorRegion.h>


namespace axtor {

typedef std::pair<BlockSet, BlockSet> BlockSetPair;
Expand Down Expand Up @@ -72,7 +72,7 @@ bool doesContainType(const llvm::Type * type, llvm::Type::TypeID id);

//bool getTypeSymbol(llvm::TypeSymbolTable & typeSymbolTable, const llvm::Type * type, std::string & out);

int getSuccessorIndex(llvm::TerminatorInst * termInst, const llvm::BasicBlock * target);
int getSuccessorIndex(llvm::Instruction * termInst, const llvm::BasicBlock * target);

/*
* checks whether there is a non-anticipated path from A to B
Expand Down
5 changes: 4 additions & 1 deletion include/axtor_c/CWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <llvm/IR/Constants.h>
#include <llvm/IR/Module.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/IR/InstrTypes.h>

#include <axtor/CommonTypes.h>
#include <axtor/writer/SyntaxWriter.h>
Expand All @@ -41,7 +42,9 @@
#include "CModuleInfo.h"

#define INDENTATION_STRING " "

namespace llvm {
class TerminatorInst;
};
namespace axtor {

class CBlockWriter;
Expand Down
2 changes: 1 addition & 1 deletion lib/axtor/CommonTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace axtor {
<< prefix << "\tcontinueBlock = " << (continueBlock ? continueBlock->getName().str() : "null") << "\n"
<< prefix << "\tbreakBlock = " << (breakBlock ? breakBlock->getName().str() : "null") << "\n"
<< prefix << "\texitBlock = " << (exitBlock ? exitBlock->getName().str() : "null") << "\n"
<< prefix << "\tparentLoop = " << (!parentLoop ? "none\n" : ""); if (parentLoop) parentLoop->dump();
<< prefix << "\tparentLoop = " << (!parentLoop ? "none\n" : ""); if (parentLoop) llvm::errs() << *parentLoop;
std::cerr << prefix << "}\n";
}

Expand Down
4 changes: 2 additions & 2 deletions lib/axtor/ast/ASTNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace ast {
return type;
}

llvm::TerminatorInst * ControlNode::getTerminator() const
llvm::Instruction * ControlNode::getTerminator() const
{
return block->getTerminator();
}
Expand Down Expand Up @@ -85,7 +85,7 @@ namespace ast {
{
#define PREFIXED std::cerr << prefix

std::string name = block ? block->getName() : "none";
std::string name = block ? block->getName().str() : "none";

std::cerr << getTypeStr() << " (" << name << ")\n";

Expand Down
4 changes: 2 additions & 2 deletions lib/axtor/ast/BasicNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace axtor
{
std::cerr << "Function " << func->getName().str() << " :\n";
std::cerr << "{\n";
getEntry()->dump();
getEntry()->dump();
std::cerr << "}\n";
}

Expand All @@ -55,7 +55,7 @@ namespace axtor

llvm::Value * ConditionalNode::getCondition() const
{
llvm::TerminatorInst * term = getBlock()->getTerminator();
llvm::Instruction * term = getBlock()->getTerminator();
return term->getOperand(0);
}

Expand Down
2 changes: 2 additions & 0 deletions lib/axtor/backend/generic/GenericCSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace axtor {
}
}

/*
while (!undeclaredStructTypes.empty()) {
for (Type * type : finder) {
// print type declaration, if all prerequesites are made
Expand All @@ -51,6 +52,7 @@ namespace axtor {
}
}
}
*/
}

std::string GenericCSerializer::getStructTypeDeclaration(const std::string & structName, const llvm::StructType * structType)
Expand Down
2 changes: 1 addition & 1 deletion lib/axtor/cns/BlockGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ BlockGraph BlockGraph::CreateFromFunction(llvm::Function & func, BlockGraph::Sub

CFG::ChildIteratorType childBegin = CFG::child_begin(block);
CFG::ChildIteratorType childEnd = CFG::child_end(block);
bb->getTerminator()->dump();
llvm::errs() << *bb->getTerminator();

for(CFG::ChildIteratorType succ = childBegin; succ != childEnd; ++succ) {
llvm::BasicBlock * dest = *succ;
Expand Down
2 changes: 1 addition & 1 deletion lib/axtor/console/CompilerLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace axtor {
assertStream();

(*msgStream) << "\n----\n";
if (func) func->dump();
if (func) llvm::errs() << *func;
(*msgStream) << "\n\terror: " << msg << '\n';
terminate();
}
Expand Down
8 changes: 4 additions & 4 deletions lib/axtor/intrinsics/AddressIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace axtor {
void AddressIterator::dump(int idx)
{
std::cerr << "ADDRESS(" << idx << ")\n";
std::cerr << "IndexVal="; val->dump();
std::cerr << "IndexVal="; llvm::errs() << *val;
std::cerr << "cumulative=" << cumulativeValue << "\n";

if (next) {
Expand Down Expand Up @@ -174,15 +174,15 @@ namespace axtor {

#ifdef DEBUG
std::cerr << "&&&&& tossFirst=" << tossFirstOffset << " ; cumulative=" << cumulativeOffset << "\n";
firstOffsetValue->dump();
llvm::errs() << *firstOffsetValue;
#endif

uint stopIndex = tossFirstOffset ? 1 : 0;
for(uint idx = gep->getNumOperands() - 1; idx > stopIndex; --idx)
{
#ifdef DEBUG
std::cerr << "!!! pushing " << idx << " of ";
gep->dump();
llvm::errs() << *gep;
#endif
llvm::Value * operandVal = gep->getOperand(idx);
next = new AddressIterator(next, operandVal, cumulativeOffset);
Expand Down Expand Up @@ -216,7 +216,7 @@ namespace axtor {

#ifdef DEBUG
std::cerr << "root value:\n";
rootValue->dump();
llvm::errs() << *rootValue;
#endif

//add a dummy
Expand Down
2 changes: 1 addition & 1 deletion lib/axtor/intrinsics/PlatformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bool PlatformInfo::implements(const llvm::Type * type, std::string typeName)
*/
bool PlatformInfo::implements(llvm::GlobalValue * gv)
{
return intrinsics.find(gv->getName()) != intrinsics.end();
return intrinsics.find(gv->getName().str()) != intrinsics.end();
}

/*
Expand Down
4 changes: 2 additions & 2 deletions lib/axtor/metainfo/ModuleInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace axtor
}

if (llvm::isa<const llvm::StructType>(type)) {
std::string structName = type->getStructName();
std::string structName = type->getStructName().str();

if (! structName.empty())
return structName;
Expand All @@ -61,6 +61,6 @@ namespace axtor
if (it != stringToType.end())
return it->second;

return M.getTypeByName(name);
return llvm::StructType::getTypeByName(M.getContext(), name);
}
}
10 changes: 5 additions & 5 deletions lib/axtor/parsers/IfParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace axtor {
{
//get successors (these might have changed after solving)
llvm::BasicBlock * entry = getEntryBlock();
llvm::TerminatorInst * termInst = entry->getTerminator();
llvm::Instruction * termInst = entry->getTerminator();
llvm::BasicBlock * onTrueBlock = termInst->getSuccessor(0);
llvm::BasicBlock * onFalseBlock = termInst->getSuccessor(1);

Expand All @@ -45,7 +45,7 @@ namespace axtor {
void IfParser::IfBuilderSession::dump()
{
llvm::BasicBlock * entry = getEntryBlock();
llvm::TerminatorInst * termInst = entry->getTerminator();
llvm::Instruction * termInst = entry->getTerminator();
llvm::BasicBlock * onTrueBlock = termInst->getSuccessor(0);
llvm::BasicBlock * onFalseBlock = termInst->getSuccessor(1);

Expand All @@ -72,7 +72,7 @@ namespace axtor {
//get successors (these might have changed after solving)

llvm::BasicBlock * entry = getEntryBlock();
llvm::TerminatorInst * termInst = entry->getTerminator();
llvm::Instruction * termInst = entry->getTerminator();
llvm::BasicBlock * onTrueBlock = termInst->getSuccessor(0);
llvm::BasicBlock * onFalseBlock = termInst->getSuccessor(1);

Expand Down Expand Up @@ -125,14 +125,14 @@ namespace axtor {
#ifdef DEBUG
std::cerr << "is leaving the loop! ignore..\n parent context:";
context.dump();
std::cerr << "this loop: " << (loop? "" : "none"); if (loop) loop->dump();
std::cerr << "this loop: " << (loop? "" : "none"); if (loop) llvm::errs() << *loop;
#endif
return NULL;
}

BlockSet regularExits = context.getRegularExits();

llvm::TerminatorInst * termInst = entry->getTerminator();
llvm::Instruction * termInst = entry->getTerminator();
llvm::BranchInst * branchInst = llvm::cast<llvm::BranchInst>(termInst);
llvm::BasicBlock * consBlock = branchInst->getSuccessor(0);
llvm::BasicBlock * altBlock = branchInst->getSuccessor(1);
Expand Down
4 changes: 2 additions & 2 deletions lib/axtor/pass/CGIPass.cpp.STASH
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ namespace axtor {

IF_DEBUG {
llvm::errs() << " ### module before Pass : \"" << getPassName() << "\"\n";
M.dump();
llvm::errs() << M;
llvm::errs() << "[EOF]\n";
}
bool retVal = session.run();
IF_DEBUG {
llvm::errs() << " ### module after Pass : \"" << getPassName() << "\"\n";
M.dump();
llvm::errs() << M;
llvm::errs() << "[EOF]\n";
}
return retVal;
Expand Down
8 changes: 4 additions & 4 deletions lib/axtor/pass/ExitUnificationPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ char ExitUnificationPass::ID = 0;

llvm::Loop * parent = loop->getParentLoop();

loop->dump();
llvm::errs() << *loop;

if (loop->getLoopDepth() <= 1) {
std::cerr << "LEE: outer-most multi exit loop\n";
Expand Down Expand Up @@ -85,7 +85,7 @@ char ExitUnificationPass::ID = 0;
//only enumerate exits to the parent loop
if (parent->contains(to))
{
llvm::TerminatorInst * term = from->getTerminator();
auto term = from->getTerminator();

for(uint succIdx = 0; succIdx < term->getNumSuccessors(); ++succIdx)
{
Expand Down Expand Up @@ -122,7 +122,7 @@ char ExitUnificationPass::ID = 0;
{
#ifdef DEBUG_LEU
std::cerr << "### Function " << func.getName().str() << " before LEU ###\n";
func.dump();
llvm::errs() << func;
#endif
llvm::LoopInfo & loopInfo = getAnalysis<llvm::LoopInfoWrapperPass>(func).getLoopInfo();

Expand Down Expand Up @@ -154,7 +154,7 @@ char ExitUnificationPass::ID = 0;
#ifdef DEBUG
std::cerr << "\n\n### Module after LEE #####\n\n";
writeModuleToFile(&M, "Lee_dump.bc");
M.dump();
llvm::errs() << M;
verifyModule(M);
#endif

Expand Down
6 changes: 3 additions & 3 deletions lib/axtor/pass/LoopBranchSeparationPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ llvm::RegisterPass<LoopBranchSeparationPass> __regLBSep("loopbranchseparator", "
#ifdef DEBUG_PASSRUN
std::cerr << "\n\n##### PASS: Loop Branch Separation #####\n\n";
std::cerr << "### BEFORE loop branch separation: \n";
mod.dump();
llvm::errs() << mod;
#endif
bool changed = false;

Expand All @@ -43,7 +43,7 @@ llvm::RegisterPass<LoopBranchSeparationPass> __regLBSep("loopbranchseparator", "

#ifdef DEBUG
std::cerr << "### AFTER loop branch separation: \n";
mod.dump();
llvm::errs() << mod;
verifyModule(mod);
#endif

Expand Down Expand Up @@ -86,7 +86,7 @@ llvm::RegisterPass<LoopBranchSeparationPass> __regLBSep("loopbranchseparator", "
}

// check all branches of n-way terminators (n > 1)
llvm::TerminatorInst * termInst = block->getTerminator();
llvm::Instruction * termInst = block->getTerminator();
llvm::Loop * loop = loopInfo.getLoopFor(&*block);

if (loop && termInst->getNumSuccessors() > 1)
Expand Down
6 changes: 3 additions & 3 deletions lib/axtor/pass/Preparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ llvm::RegisterPass<Preparator> __regPreparator("preparator", "axtor - preparator
llvm::Instruction * assignInst = createAssignment(inst, bridgeBlock);

//redirect all branches from the source block to the bridge block
llvm::TerminatorInst * termInst = branchBlock->getTerminator();
llvm::Instruction * termInst = branchBlock->getTerminator();
for(uint i = 0; i < termInst->getNumSuccessors(); ++i)
{
if (termInst->getSuccessor(i) == branchTarget)
Expand Down Expand Up @@ -235,7 +235,7 @@ llvm::RegisterPass<Preparator> __regPreparator("preparator", "axtor - preparator

// only remove the class. / struct. prefix from opaque types, if existent
if (structType->getStructNumElements() == 0) {
std::string opaqueName = structType->getStructName();
std::string opaqueName = structType->getStructName().str();
if (opaqueName.substr(0, 6) == "class.") {
opaqueName = opaqueName.substr(6, std::string::npos);
} else if (opaqueName.substr(0, 7) == "struct.") {
Expand Down Expand Up @@ -310,7 +310,7 @@ llvm::RegisterPass<Preparator> __regPreparator("preparator", "axtor - preparator
#ifdef DEBUG
verifyModule(M);
std::cerr << "\n##### module after preparations #####\n";
M.dump();
llvm::errs() << M;
#endif

return true;
Expand Down
Loading