Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: src/llvm2ice.cpp

Issue 659513005: Allow conditional lit tests in Subzero, based on build flags. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Use REQUIRES when appropriate in lit tests. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« pydir/ifatts.py ('K') | « pydir/ifatts.py ('k') | tests_lit/lit.cfg » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/llvm2ice.cpp
diff --git a/src/llvm2ice.cpp b/src/llvm2ice.cpp
index 3546b84c87bfacfc63c77f757103f0fd2ca225df..dc7c65a7e59a7d010235986af1e5bf2f8ca42648 100644
--- a/src/llvm2ice.cpp
+++ b/src/llvm2ice.cpp
@@ -16,6 +16,7 @@
#include <fstream>
#include <iostream>
+#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/Support/CommandLine.h"
@@ -161,12 +162,58 @@ static cl::opt<bool> AlwaysExitSuccess(
"exit-success", cl::desc("Exit with success status, even if errors found"),
cl::init(false));
+static cl::opt<bool> GenerateBuildAtts(
+ "build-atts", cl::desc("Generate list of build attributes associated with "
+ "this executable."),
+ cl::init(false));
+
static int GetReturnValue(int Val) {
if (AlwaysExitSuccess)
return 0;
return Val;
}
+static struct {
+ const char *FlagName;
+ int FlagValue;
+} ConditionalBuildAttributes[] = {
+ { "text_asm", ALLOW_TEXT_ASM },
+ { "dump", ALLOW_DUMP },
+ { "llvm_cl", ALLOW_LLVM_CL },
+ { "llvm_ir", ALLOW_LLVM_IR },
+ { "llvm_ir_as_input", ALLOW_LLVM_IR_AS_INPUT }
+};
+
+// Validates values of build attributes. Prints them to Stream if
+// Stream is non-null.
+static void ValidateAndGenerateBuildAttributes(raw_os_ostream *Stream) {
+
+ // TODO(kschimpf): Conditionalize this once we have multiple targets.
Jim Stichnoth 2014/10/21 21:58:41 After the GlobalContext object is created, you cou
Karl 2014/10/22 17:03:36 Done.
+ if (Stream)
+ *Stream << "x86-32\n";
+
+ for (size_t i = 0; i < array_lengthof(ConditionalBuildAttributes); ++i) {
+ switch (ConditionalBuildAttributes[i].FlagValue) {
+ case 0:
+ if (Stream)
+ *Stream << "no_" << ConditionalBuildAttributes[i].FlagName << "\n";
+ break;
+ case 1:
+ if (Stream)
+ *Stream << "allow_" << ConditionalBuildAttributes[i].FlagName << "\n";
+ break;
+ default: {
+ std::string Buffer;
+ raw_string_ostream StrBuf(Buffer);
+ StrBuf << "Flag " << ConditionalBuildAttributes[i].FlagName
+ << " must be defined as 0/1. Found: "
+ << ConditionalBuildAttributes[i].FlagValue;
+ report_fatal_error(StrBuf.str());
+ }
+ }
+ }
+}
+
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv);
@@ -182,6 +229,11 @@ int main(int argc, char **argv) {
raw_os_ostream *Os =
new raw_os_ostream(OutputFilename == "-" ? std::cout : Ofs);
Os->SetUnbuffered();
+
+ ValidateAndGenerateBuildAttributes(GenerateBuildAtts ? Os : nullptr);
+ if (GenerateBuildAtts)
+ return GetReturnValue(0);
+
std::ofstream Lfs;
if (LogFilename != "-") {
Lfs.open(LogFilename.c_str(), std::ofstream::out);
« pydir/ifatts.py ('K') | « pydir/ifatts.py ('k') | tests_lit/lit.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698