diff options
author | Dan Gohman <djg@cray.com> | 2007-07-18 16:29:46 +0000 |
---|---|---|
committer | Dan Gohman <djg@cray.com> | 2007-07-18 16:29:46 +0000 |
commit | f17a25c88b892d30c2b41ba7ecdfbdfb2b4be9cc (patch) | |
tree | ebb79ea1ee5e3bc1fdf38541a811a8b804f0679a /include/llvm/Assembly | |
download | external_llvm-f17a25c88b892d30c2b41ba7ecdfbdfb2b4be9cc.zip external_llvm-f17a25c88b892d30c2b41ba7ecdfbdfb2b4be9cc.tar.gz external_llvm-f17a25c88b892d30c2b41ba7ecdfbdfb2b4be9cc.tar.bz2 |
It's not necessary to do rounding for alloca operations when the requested
alignment is equal to the stack alignment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Assembly')
-rw-r--r-- | include/llvm/Assembly/AsmAnnotationWriter.h | 53 | ||||
-rw-r--r-- | include/llvm/Assembly/Parser.h | 97 | ||||
-rw-r--r-- | include/llvm/Assembly/PrintModulePass.h | 81 | ||||
-rw-r--r-- | include/llvm/Assembly/Writer.h | 45 |
4 files changed, 276 insertions, 0 deletions
diff --git a/include/llvm/Assembly/AsmAnnotationWriter.h b/include/llvm/Assembly/AsmAnnotationWriter.h new file mode 100644 index 0000000..9ed285a --- /dev/null +++ b/include/llvm/Assembly/AsmAnnotationWriter.h @@ -0,0 +1,53 @@ +//===-- AsmAnnotationWriter.h - Itf for annotation .ll files - --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Clients of the assembly writer can use this interface to add their own +// special-purpose annotations to LLVM assembly language printouts. Note that +// the assembly parser won't be able to parse these, in general, so +// implementations are advised to print stuff as LLVM comments. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ASSEMBLY_ASMANNOTATIONWRITER_H +#define LLVM_ASSEMBLY_ASMANNOTATIONWRITER_H + +#include <iosfwd> + +namespace llvm { + +class Function; +class BasicBlock; +class Instruction; + +struct AssemblyAnnotationWriter { + + virtual ~AssemblyAnnotationWriter(); + + // emitFunctionAnnot - This may be implemented to emit a string right before + // the start of a function. + virtual void emitFunctionAnnot(const Function *F, std::ostream &OS) {} + + // emitBasicBlockStartAnnot - This may be implemented to emit a string right + // after the basic block label, but before the first instruction in the block. + virtual void emitBasicBlockStartAnnot(const BasicBlock *BB, std::ostream &OS){ + } + + // emitBasicBlockEndAnnot - This may be implemented to emit a string right + // after the basic block. + virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, std::ostream &OS){ + } + + // emitInstructionAnnot - This may be implemented to emit a string right + // before an instruction is emitted. + virtual void emitInstructionAnnot(const Instruction *I, std::ostream &OS) {} +}; + +} // End llvm namespace + +#endif diff --git a/include/llvm/Assembly/Parser.h b/include/llvm/Assembly/Parser.h new file mode 100644 index 0000000..bc7995e --- /dev/null +++ b/include/llvm/Assembly/Parser.h @@ -0,0 +1,97 @@ +//===-- llvm/Assembly/Parser.h - Parser for VM assembly files ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// These classes are implemented by the lib/AsmParser library. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ASSEMBLY_PARSER_H +#define LLVM_ASSEMBLY_PARSER_H + +#include <string> + +namespace llvm { + +class Module; +class ParseError; + + +/// This function is the main interface to the LLVM Assembly Parse. It parses +/// an ascii file that (presumably) contains LLVM Assembly code. It returns a +/// Module (intermediate representation) with the corresponding features. Note +/// that this does not verify that the generated Module is valid, so you should +/// run the verifier after parsing the file to check that it is okay. +/// @brief Parse LLVM Assembly from a file +Module *ParseAssemblyFile( + const std::string &Filename, ///< The name of the file to parse + ParseError* Error = 0 ///< If not null, an object to return errors in. +); + +/// The function is a secondary interface to the LLVM Assembly Parse. It parses +/// an ascii string that (presumably) contains LLVM Assembly code. It returns a +/// Module (intermediate representation) with the corresponding features. Note +/// that this does not verify that the generated Module is valid, so you should +/// run the verifier after parsing the file to check that it is okay. +/// @brief Parse LLVM Assembly from a string +Module *ParseAssemblyString( + const char * AsmString, ///< The string containing assembly + Module * M, ///< A module to add the assembly too. + ParseError* Error = 0 ///< If not null, an object to return errors in. +); + +//===------------------------------------------------------------------------=== +// Helper Classes +//===------------------------------------------------------------------------=== + +/// An instance of this class can be passed to ParseAssemblyFile or +/// ParseAssemblyString functions in order to capture error information from +/// the parser. It provides a standard way to print out the error message +/// including the file name and line number where the error occurred. +/// @brief An LLVM Assembly Parsing Error Object +class ParseError { +public: + ParseError() : Filename("unknown"), Message("none"), LineNo(0), ColumnNo(0) {} + ParseError(const ParseError &E); + + // getMessage - Return the message passed in at construction time plus extra + // information extracted from the options used to parse with... + // + const std::string getMessage() const; + + inline const std::string &getRawMessage() const { // Just the raw message... + return Message; + } + + inline const std::string &getFilename() const { + return Filename; + } + + void setError(const std::string &filename, const std::string &message, + int LineNo = -1, int ColNo = -1); + + // getErrorLocation - Return the line and column number of the error in the + // input source file. The source filename can be derived from the + // ParserOptions in effect. If positional information is not applicable, + // these will return a value of -1. + // + inline const void getErrorLocation(int &Line, int &Column) const { + Line = LineNo; Column = ColumnNo; + } + +private : + std::string Filename; + std::string Message; + int LineNo, ColumnNo; // -1 if not relevant + + ParseError &operator=(const ParseError &E); // objects by reference +}; + +} // End llvm namespace + +#endif diff --git a/include/llvm/Assembly/PrintModulePass.h b/include/llvm/Assembly/PrintModulePass.h new file mode 100644 index 0000000..0f65235 --- /dev/null +++ b/include/llvm/Assembly/PrintModulePass.h @@ -0,0 +1,81 @@ +//===- llvm/Assembly/PrintModulePass.h - Printing Pass ----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines two passes to print out a module. The PrintModulePass pass +// simply prints out the entire module when it is executed. The +// PrintFunctionPass class is designed to be pipelined with other +// FunctionPass's, and prints out the functions of the class as they are +// processed. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ASSEMBLY_PRINTMODULEPASS_H +#define LLVM_ASSEMBLY_PRINTMODULEPASS_H + +#include "llvm/Pass.h" +#include "llvm/Module.h" +#include "llvm/Support/Streams.h" + +namespace llvm { + +class PrintModulePass : public ModulePass { + OStream *Out; // ostream to print on + bool DeleteStream; // Delete the ostream in our dtor? +public: + static char ID; + PrintModulePass() : ModulePass((intptr_t)&ID), Out(&cerr), DeleteStream(false) {} + PrintModulePass(OStream *o, bool DS = false) + : ModulePass((intptr_t)&ID), Out(o), DeleteStream(DS) {} + + ~PrintModulePass() { + if (DeleteStream) delete Out; + } + + bool runOnModule(Module &M) { + (*Out) << M << std::flush; + return false; + } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } +}; + +class PrintFunctionPass : public FunctionPass { + std::string Banner; // String to print before each function + OStream *Out; // ostream to print on + bool DeleteStream; // Delete the ostream in our dtor? +public: + static char ID; + PrintFunctionPass() : FunctionPass((intptr_t)&ID), Banner(""), Out(&cerr), + DeleteStream(false) {} + PrintFunctionPass(const std::string &B, OStream *o = &cout, + bool DS = false) + : FunctionPass((intptr_t)&ID), Banner(B), Out(o), DeleteStream(DS) {} + + inline ~PrintFunctionPass() { + if (DeleteStream) delete Out; + } + + // runOnFunction - This pass just prints a banner followed by the function as + // it's processed. + // + bool runOnFunction(Function &F) { + (*Out) << Banner << static_cast<Value&>(F); + return false; + } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } +}; + +} // End llvm namespace + +#endif diff --git a/include/llvm/Assembly/Writer.h b/include/llvm/Assembly/Writer.h new file mode 100644 index 0000000..45c9513 --- /dev/null +++ b/include/llvm/Assembly/Writer.h @@ -0,0 +1,45 @@ +//===-- llvm/Assembly/Writer.h - Printer for LLVM assembly files --*- C++ -*-=// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This functionality is implemented by lib/VMCore/AsmWriter.cpp. +// This library is used to print LLVM assembly language files to an iostream. It +// can print LLVM code at a variety of granularities, including Modules, +// BasicBlocks, and Instructions. This makes it useful for debugging. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ASSEMBLY_WRITER_H +#define LLVM_ASSEMBLY_WRITER_H + +#include <iosfwd> + +namespace llvm { + +class Type; +class Module; +class Value; + +// WriteTypeSymbolic - This attempts to write the specified type as a symbolic +// type, iff there is an entry in the Module's symbol table for the specified +// type or one of its component types. This is slower than a simple x << Type; +// +std::ostream &WriteTypeSymbolic(std::ostream &, const Type *, const Module *M); + +// WriteAsOperand - Write the name of the specified value out to the specified +// ostream. This can be useful when you just want to print int %reg126, not the +// whole instruction that generated it. If you specify a Module for context, +// then even constants get pretty-printed; for example, the type of a null +// pointer is printed symbolically. +// +std::ostream &WriteAsOperand(std::ostream &, const Value *, bool PrintTy = true, + const Module *Context = 0); + +} // End llvm namespace + +#endif |