diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-07-21 12:39:30 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-07-21 12:39:30 +0000 |
commit | 9ad9f09ef2d6ddc8be51d70d4af6db8fb6eb9565 (patch) | |
tree | bbf55e8fd81a7352a6fcef884a38b90e5d7da933 | |
parent | 23ee550765232e22d0daf6407141ecef4c55c06f (diff) | |
download | external_llvm-9ad9f09ef2d6ddc8be51d70d4af6db8fb6eb9565.zip external_llvm-9ad9f09ef2d6ddc8be51d70d4af6db8fb6eb9565.tar.gz external_llvm-9ad9f09ef2d6ddc8be51d70d4af6db8fb6eb9565.tar.bz2 |
CompileContext and options class for the llc compiler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/LLC/CompileContext.h | 69 | ||||
-rw-r--r-- | include/llvm/LLC/LLCOptions.h | 84 |
2 files changed, 153 insertions, 0 deletions
diff --git a/include/llvm/LLC/CompileContext.h b/include/llvm/LLC/CompileContext.h new file mode 100644 index 0000000..88e35d6 --- /dev/null +++ b/include/llvm/LLC/CompileContext.h @@ -0,0 +1,69 @@ +// $Id$ -*-c++-*- +//*************************************************************************** +// class CompileContext +// +// Purpose: +// Holds the common option and target information for a compilation run. +// +// History: +// 07/15/01 - vadve - Created +// +//**************************************************************************/ + +#ifndef LLVM_LLC_COMPILECONTEXT_H +#define LLVM_LLC_COMPILECONTEXT_H + +//************************** System Include Files **************************/ + +#include <string> + +//*************************** User Include Files ***************************/ + +#include "llvm/Codegen/Sparc.h" +#include "llvm/LLC/LLCOptions.h" + +//************************** Forward Declarations **************************/ + +class ProgramOptions; +class TargetMachine; + + +//--------------------------------------------------------------------------- +// class CompileContext +//--------------------------------------------------------------------------- + +class CompileContext: public Unique +{ +private: + LLCOptions* options; + TargetMachine* targetMachine; + +public: + /*ctor*/ CompileContext (int argc, const char **argv, const char** envp); + /*dtor*/ virtual ~CompileContext (); + + const LLCOptions& getOptions () const { return *options; } + + const TargetMachine& getTarget () const { return *targetMachine; } + TargetMachine& getTarget () { return *targetMachine; } +}; + + +inline +CompileContext::CompileContext(int argc, const char **argv, const char** envp) +{ + options = new LLCOptions(argc, argv, envp); + targetMachine = new UltraSparc; +} + + +inline +CompileContext::~CompileContext() +{ + delete options; + delete targetMachine; +} + +//**************************************************************************/ + +#endif diff --git a/include/llvm/LLC/LLCOptions.h b/include/llvm/LLC/LLCOptions.h new file mode 100644 index 0000000..56e963a --- /dev/null +++ b/include/llvm/LLC/LLCOptions.h @@ -0,0 +1,84 @@ +// $Id$ -*-c++-*- +//**************************************************************************/ +// File: +// LLCOptions.h +// +// Purpose: +// Options for the llc compiler. +// +// History: +// 7/15/01 - Vikram Adve - Created +// +//**************************************************************************/ + +#ifndef LLVM_LLC_LLCOPTIONS_H +#define LLVM_LLC_LLCOPTIONS_H + +//************************** System Include Files **************************/ + +#include <iostream.h> +#include <unistd.h> + + +//*************************** User Include Files ***************************/ + +#include "llvm/Support/ProgramOptions.h" +#include "llvm/Support/ProgramOption.h" + +//************************ Option Name Definitions *************************/ + +const char* const HELP_OPT = "help"; +const char* const DEBUG_OPT = "d"; +const char* const QUIET_OPT = "q"; +const char* const DEBUG_INSTR_SELECT_OPT= "debug_select"; +const char* const OUTFILENAME_OPT = "o"; + + +//--------------------------------------------------------------------------- +// class LLCOptions +//--------------------------------------------------------------------------- + +class LLCOptions : public ProgramOptions { +public: + /*ctor*/ LLCOptions (int _argc, + const char* _argv[], + const char* _envp[]); + /*dtor*/ virtual ~LLCOptions (); + + const string& getInputFileName() const { return inputFileName; } + + const string& getOutputFileName() const { return outputFileName; } + +protected: + + //-------------------------------------------------------------------- + // Initialize for all our compiler options (called by constructors). + //-------------------------------------------------------------------- + void InitializeOptions(); + + //-------------------------------------------------------------------- + // Make sure the parse went ok. + //-------------------------------------------------------------------- + void CheckParse(); + + //-------------------------------------------------------------------- + // Parse arguments after all options are consumed. + // This is called after a successful ParseArgs. + //-------------------------------------------------------------------- + virtual void ParseExtraArgs(); + + //-------------------------------------------------------------------- + // Print message describing which arguments and options are + // required, optional, mutually exclusive, ... + // called in ProgramOptions::Usage() method + //-------------------------------------------------------------------- + virtual void PrintUsage(ostream& stream) const; + +private: + string inputFileName; + string outputFileName; +}; + +//**************************************************************************/ + +#endif |