aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-08-24 14:03:23 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-08-24 14:03:23 +0000
commitf384db3a9094619c1c3ad5721dbbe007bc153fcf (patch)
tree5be3643289697edf3a39f8a9268cfb5ac4164734 /tools
parentbf3948884e8e04fadd27993aee8794752b4b8014 (diff)
downloadexternal_llvm-f384db3a9094619c1c3ad5721dbbe007bc153fcf.zip
external_llvm-f384db3a9094619c1c3ad5721dbbe007bc153fcf.tar.gz
external_llvm-f384db3a9094619c1c3ad5721dbbe007bc153fcf.tar.bz2
- Implement the %args% substitution
- Implement parsing of the .output={bytecode|assembly} item. - Drop parsing support for translator.optimizes, translator.groks_dash_O, optimizer.groks_dash_O, translator.output_is_asm, optimizer.output_is_asm - Add parsing support for translator.output and optimizer.output - Add optimizer.required parsing support - Add linker.libs and linker.libpaths parsing support - Fix error messages to list correct set of tokens expected. - Rename FileReadable -> FileIsReadable (changed in CompilerDriver.cpp) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16023 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvmc/Configuration.cpp85
1 files changed, 46 insertions, 39 deletions
diff --git a/tools/llvmc/Configuration.cpp b/tools/llvmc/Configuration.cpp
index a3c62d6..4770875 100644
--- a/tools/llvmc/Configuration.cpp
+++ b/tools/llvmc/Configuration.cpp
@@ -25,7 +25,7 @@ using namespace llvm;
namespace sys {
// From CompilerDriver.cpp (for now)
- extern bool FileReadable(const std::string& fname);
+ extern bool FileIsReadable(const std::string& fname);
}
namespace llvm {
@@ -155,6 +155,7 @@ namespace {
bool parseSubstitution(CompilerDriver::StringVector& optList) {
switch (token) {
+ case ARGS_SUBST: optList.push_back("%args%"); break;
case IN_SUBST: optList.push_back("%in%"); break;
case OUT_SUBST: optList.push_back("%out%"); break;
case TIME_SUBST: optList.push_back("%time%"); break;
@@ -256,11 +257,31 @@ namespace {
confDat->PreProcessor.clear(CompilerDriver::REQUIRED_FLAG);
break;
default:
- error("Expecting 'command' or 'required'");
+ error("Expecting 'command' or 'required' but found '" +
+ ConfigLexerState.StringVal);
break;
}
}
+ bool parseOutputFlag() {
+ if (next() == EQUALS) {
+ if (next() == ASSEMBLY) {
+ return true;
+ } else if (token == BYTECODE) {
+ return false;
+ } else {
+ error("Expecting output type value");
+ return false;
+ }
+ if (next() != EOLTOK && token != 0) {
+ error("Extraneous tokens after output value");
+ }
+ }
+ else
+ error("Expecting '='");
+ return false;
+ }
+
void parseTranslator() {
switch (next()) {
case COMMAND:
@@ -278,28 +299,17 @@ namespace {
else
confDat->Translator.clear(CompilerDriver::PREPROCESSES_FLAG);
break;
- case OPTIMIZES:
- if (parseBoolean())
- confDat->Translator.set(CompilerDriver::OPTIMIZES_FLAG);
- else
- confDat->Translator.clear(CompilerDriver::OPTIMIZES_FLAG);
- break;
- case GROKS_DASH_O:
- if (parseBoolean())
- confDat->Translator.set(CompilerDriver::GROKS_DASH_O_FLAG);
- else
- confDat->Translator.clear(CompilerDriver::GROKS_DASH_O_FLAG);
- break;
- case OUTPUT_IS_ASM:
- if (parseBoolean())
+ case OUTPUT:
+ if (parseOutputFlag())
confDat->Translator.set(CompilerDriver::OUTPUT_IS_ASM_FLAG);
else
confDat->Translator.clear(CompilerDriver::OUTPUT_IS_ASM_FLAG);
break;
default:
- error("Expecting 'command', 'required', 'preprocesses', "
- "'groks_dash_O' or 'optimizes'");
+ error("Expecting 'command', 'required', 'preprocesses', or "
+ "'output' but found '" + ConfigLexerState.StringVal +
+ "' instead");
break;
}
}
@@ -321,20 +331,22 @@ namespace {
else
confDat->Optimizer.clear(CompilerDriver::TRANSLATES_FLAG);
break;
- case GROKS_DASH_O:
+ case REQUIRED:
if (parseBoolean())
- confDat->Optimizer.set(CompilerDriver::GROKS_DASH_O_FLAG);
+ confDat->Optimizer.set(CompilerDriver::REQUIRED_FLAG);
else
- confDat->Optimizer.clear(CompilerDriver::GROKS_DASH_O_FLAG);
+ confDat->Optimizer.clear(CompilerDriver::REQUIRED_FLAG);
break;
- case OUTPUT_IS_ASM:
- if (parseBoolean())
+ case OUTPUT:
+ if (parseOutputFlag())
confDat->Translator.set(CompilerDriver::OUTPUT_IS_ASM_FLAG);
else
confDat->Translator.clear(CompilerDriver::OUTPUT_IS_ASM_FLAG);
break;
default:
- error("Expecting 'command' or 'groks_dash_O'");
+ error(std::string("Expecting 'command', 'preprocesses', ") +
+ "'translates' or 'output' but found '" +
+ ConfigLexerState.StringVal + "' instead");
break;
}
}
@@ -352,17 +364,12 @@ namespace {
void parseLinker() {
switch(next()) {
- case COMMAND:
- parseCommand(confDat->Linker);
- break;
- case GROKS_DASH_O:
- if (parseBoolean())
- confDat->Linker.set(CompilerDriver::GROKS_DASH_O_FLAG);
- else
- confDat->Linker.clear(CompilerDriver::GROKS_DASH_O_FLAG);
- break;
+ case LIBS:
+ break; //FIXME
+ case LIBPATHS:
+ break; //FIXME
default:
- error("Expecting 'command'");
+ error("Expecting 'libs' or 'libpaths'");
break;
}
}
@@ -415,7 +422,7 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
if (conf) {
dir_name = conf;
dir_name += "/";
- if (!::sys::FileReadable(dir_name + ftype))
+ if (!::sys::FileIsReadable(dir_name + ftype))
throw "Configuration file for '" + ftype + "' is not available.";
} else {
// Try the user's home directory
@@ -423,14 +430,14 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
if (home) {
dir_name = home;
dir_name += "/.llvm/etc/";
- if (!::sys::FileReadable(dir_name + ftype)) {
+ if (!::sys::FileIsReadable(dir_name + ftype)) {
// Okay, try the LLVM installation directory
dir_name = LLVM_ETCDIR;
dir_name += "/";
- if (!::sys::FileReadable(dir_name + ftype)) {
+ if (!::sys::FileIsReadable(dir_name + ftype)) {
// Okay, try the "standard" place
dir_name = "/etc/llvm/";
- if (!::sys::FileReadable(dir_name + ftype)) {
+ if (!::sys::FileIsReadable(dir_name + ftype)) {
throw "Configuration file for '" + ftype + "' is not available.";
}
}
@@ -439,7 +446,7 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
}
} else {
dir_name = configDir + "/";
- if (!::sys::FileReadable(dir_name + ftype)) {
+ if (!::sys::FileIsReadable(dir_name + ftype)) {
throw "Configuration file for '" + ftype + "' is not available.";
}
}