[llvm-commits] [parallel] CVS: llvm/include/llvm/Support/GetElementPtrTypeIterator.h Mangler.h ToolRunner.h
Misha Brukman
brukman at cs.uiuc.edu
Mon Mar 1 17:59:05 PST 2004
Changes in directory llvm/include/llvm/Support:
GetElementPtrTypeIterator.h updated: 1.4 -> 1.4.4.1
Mangler.h updated: 1.8 -> 1.8.4.1
ToolRunner.h updated: 1.6 -> 1.6.4.1
---
Log message:
Merge from trunk
---
Diffs of the changes: (+74 -42)
Index: llvm/include/llvm/Support/GetElementPtrTypeIterator.h
diff -u llvm/include/llvm/Support/GetElementPtrTypeIterator.h:1.4 llvm/include/llvm/Support/GetElementPtrTypeIterator.h:1.4.4.1
--- llvm/include/llvm/Support/GetElementPtrTypeIterator.h:1.4 Thu Dec 11 22:58:13 2003
+++ llvm/include/llvm/Support/GetElementPtrTypeIterator.h Mon Mar 1 17:57:19 2004
@@ -15,8 +15,7 @@
#ifndef LLVM_SUPPORT_GETELEMENTPTRTYPE_H
#define LLVM_SUPPORT_GETELEMENTPTRTYPE_H
-#include "Support/iterator"
-#include "llvm/iMemory.h"
+#include "llvm/User.h"
#include "llvm/DerivedTypes.h"
namespace llvm {
@@ -24,30 +23,26 @@
: public forward_iterator<const Type *, ptrdiff_t> {
typedef forward_iterator<const Type*, ptrdiff_t> super;
- User *TheGEP; // Either GetElementPtrInst or ConstantExpr
+ User::op_iterator OpIt;
const Type *CurTy;
- unsigned Operand;
-
gep_type_iterator() {}
public:
- static gep_type_iterator begin(User *gep) {
+ static gep_type_iterator begin(const Type *Ty, User::op_iterator It) {
gep_type_iterator I;
- I.TheGEP = gep;
- I.CurTy = gep->getOperand(0)->getType();
- I.Operand = 1;
+ I.CurTy = Ty;
+ I.OpIt = It;
return I;
}
- static gep_type_iterator end(User *gep) {
+ static gep_type_iterator end(User::op_iterator It) {
gep_type_iterator I;
- I.TheGEP = gep;
I.CurTy = 0;
- I.Operand = gep->getNumOperands();
+ I.OpIt = It;
return I;
}
bool operator==(const gep_type_iterator& x) const {
- return Operand == x.Operand;
+ return OpIt == x.OpIt;
}
bool operator!=(const gep_type_iterator& x) const {
return !operator==(x);
@@ -61,9 +56,7 @@
// current type directly.
const Type *operator->() const { return operator*(); }
- unsigned getOperandNum() const { return Operand; }
-
- Value *getOperand() const { return TheGEP->getOperand(Operand); }
+ Value *getOperand() const { return *OpIt; }
gep_type_iterator& operator++() { // Preincrement
if (const CompositeType *CT = dyn_cast<CompositeType>(CurTy)) {
@@ -71,7 +64,7 @@
} else {
CurTy = 0;
}
- ++Operand;
+ ++OpIt;
return *this;
}
@@ -81,18 +74,26 @@
};
inline gep_type_iterator gep_type_begin(User *GEP) {
- return gep_type_iterator::begin(GEP);
+ return gep_type_iterator::begin(GEP->getOperand(0)->getType(),
+ GEP->op_begin()+1);
}
-
inline gep_type_iterator gep_type_end(User *GEP) {
- return gep_type_iterator::end(GEP);
+ return gep_type_iterator::end(GEP->op_end());
}
inline gep_type_iterator gep_type_begin(User &GEP) {
- return gep_type_iterator::begin(&GEP);
+ return gep_type_iterator::begin(GEP.getOperand(0)->getType(),
+ GEP.op_begin()+1);
}
-
inline gep_type_iterator gep_type_end(User &GEP) {
- return gep_type_iterator::end(&GEP);
+ return gep_type_iterator::end(GEP.op_end());
+ }
+ inline gep_type_iterator gep_type_begin(const Type *Op0, User::op_iterator I,
+ User::op_iterator E) {
+ return gep_type_iterator::begin(Op0, I);
+ }
+ inline gep_type_iterator gep_type_end(const Type *Op0, User::op_iterator I,
+ User::op_iterator E) {
+ return gep_type_iterator::end(E);
}
} // end namespace llvm
Index: llvm/include/llvm/Support/Mangler.h
diff -u llvm/include/llvm/Support/Mangler.h:1.8 llvm/include/llvm/Support/Mangler.h:1.8.4.1
--- llvm/include/llvm/Support/Mangler.h:1.8 Tue Nov 11 16:41:31 2003
+++ llvm/include/llvm/Support/Mangler.h Mon Mar 1 17:57:19 2004
@@ -1,4 +1,4 @@
-//===-- Mangler.h - Self-contained c/asm llvm name mangler ------*- C++ -*-===//
+//===-- Mangler.h - Self-contained llvm name mangler ------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,25 +7,21 @@
//
//===----------------------------------------------------------------------===//
//
-// Unified name mangler for CWriter and assembly backends.
+// Unified name mangler for various backends.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_MANGLER_H
#define LLVM_SUPPORT_MANGLER_H
-namespace llvm {
-
-class Value;
-class Module;
-
-} // End llvm namespace
-
#include <map>
#include <set>
#include <string>
namespace llvm {
+class Value;
+class Module;
+class GlobalValue;
class Mangler {
/// This keeps track of which global values have had their names
@@ -40,6 +36,8 @@
ValueMap Memo;
unsigned Count;
+
+ void InsertName(GlobalValue *GV, std::map<std::string, GlobalValue*> &Names);
public:
// Mangler ctor - if AddUnderscorePrefix is true, then all public global
Index: llvm/include/llvm/Support/ToolRunner.h
diff -u llvm/include/llvm/Support/ToolRunner.h:1.6 llvm/include/llvm/Support/ToolRunner.h:1.6.4.1
--- llvm/include/llvm/Support/ToolRunner.h:1.6 Tue Nov 11 16:41:31 2003
+++ llvm/include/llvm/Support/ToolRunner.h Mon Mar 1 17:57:19 2004
@@ -18,6 +18,7 @@
#define TOOLRUNNER_H
#include "Support/SystemUtils.h"
+#include <exception>
#include <vector>
namespace llvm {
@@ -25,6 +26,20 @@
class CBE;
class LLC;
+
+/// ToolExecutionError - An instance of this class is thrown by the
+/// AbstractInterpreter instances if there is an error running a tool (e.g., LLC
+/// crashes) which prevents execution of the program.
+///
+class ToolExecutionError : std::exception {
+ std::string Message;
+public:
+ explicit ToolExecutionError(const std::string &M) : Message(M) {}
+ virtual ~ToolExecutionError() throw();
+ virtual const char* what() const throw() { return Message.c_str(); }
+};
+
+
//===---------------------------------------------------------------------===//
// GCC abstraction
//
@@ -56,9 +71,6 @@
///
int MakeSharedObject(const std::string &InputFile, FileType fileType,
std::string &OutputFile);
-
-private:
- void ProcessFailure(const char **Args);
};
@@ -80,6 +92,12 @@
virtual ~AbstractInterpreter() {}
+ /// compileProgram - Compile the specified program from bytecode to executable
+ /// code. This does not produce any output, it is only used when debugging
+ /// the code generator. If the code generator fails, an exception should be
+ /// thrown, otherwise, this function will just return.
+ virtual void compileProgram(const std::string &Bytecode) {}
+
/// ExecuteProgram - Run the specified bytecode file, emitting output to the
/// specified filename. This returns the exit code of the program.
///
@@ -95,12 +113,18 @@
// CBE Implementation of AbstractIntepreter interface
//
class CBE : public AbstractInterpreter {
- std::string DISPath; // The path to the `llvm-dis' executable
+ std::string LLCPath; // The path to the `llc' executable
GCC *gcc;
public:
- CBE(const std::string &disPath, GCC *Gcc) : DISPath(disPath), gcc(Gcc) { }
+ CBE(const std::string &llcPath, GCC *Gcc) : LLCPath(llcPath), gcc(Gcc) { }
~CBE() { delete gcc; }
+ /// compileProgram - Compile the specified program from bytecode to executable
+ /// code. This does not produce any output, it is only used when debugging
+ /// the code generator. If the code generator fails, an exception should be
+ /// thrown, otherwise, this function will just return.
+ virtual void compileProgram(const std::string &Bytecode);
+
virtual int ExecuteProgram(const std::string &Bytecode,
const std::vector<std::string> &Args,
const std::string &InputFile,
@@ -108,10 +132,11 @@
const std::vector<std::string> &SharedLibs =
std::vector<std::string>());
- // Sometimes we just want to go half-way and only generate the .c file,
- // not necessarily compile it with GCC and run the program.
+ // Sometimes we just want to go half-way and only generate the .c file, not
+ // necessarily compile it with GCC and run the program. This throws an
+ // exception if LLC crashes.
//
- virtual int OutputC(const std::string &Bytecode, std::string &OutputCFile);
+ virtual void OutputC(const std::string &Bytecode, std::string &OutputCFile);
};
@@ -126,6 +151,13 @@
: LLCPath(llcPath), gcc(Gcc) { }
~LLC() { delete gcc; }
+
+ /// compileProgram - Compile the specified program from bytecode to executable
+ /// code. This does not produce any output, it is only used when debugging
+ /// the code generator. If the code generator fails, an exception should be
+ /// thrown, otherwise, this function will just return.
+ virtual void compileProgram(const std::string &Bytecode);
+
virtual int ExecuteProgram(const std::string &Bytecode,
const std::vector<std::string> &Args,
const std::string &InputFile,
@@ -134,9 +166,10 @@
std::vector<std::string>());
// Sometimes we just want to go half-way and only generate the .s file,
- // not necessarily compile it all the way and run the program.
+ // not necessarily compile it all the way and run the program. This throws
+ // an exception if execution of LLC fails.
//
- int OutputAsm(const std::string &Bytecode, std::string &OutputAsmFile);
+ void OutputAsm(const std::string &Bytecode, std::string &OutputAsmFile);
};
} // End llvm namespace
More information about the llvm-commits
mailing list