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

Unified Diff: src/llvm2ice.cpp

Issue 265703002: Add Om1 lowering with no optimizations (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Add frem test; add LOWERING.rst file Created 6 years, 7 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
Index: src/llvm2ice.cpp
diff --git a/src/llvm2ice.cpp b/src/llvm2ice.cpp
index df9061b8d73033e406e8b40d4709a34f939a047b..e3a2009a270293bece248c8d0b4503b8b613de6f 100644
--- a/src/llvm2ice.cpp
+++ b/src/llvm2ice.cpp
@@ -165,8 +165,9 @@ private:
return Ice::IceType_void;
}
- // Given a LLVM instruction and an operand number, produce the Operand this
- // refers to. If there's no such operand, return NULL.
+ // Given an LLVM instruction and an operand number, produce the
+ // Ice::Operand this refers to. If there's no such operand, return
+ // NULL.
Ice::Operand *convertOperand(const Instruction *Inst, unsigned OpNum) {
if (OpNum >= Inst->getNumOperands()) {
return NULL;
@@ -189,10 +190,10 @@ private:
return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat());
else if (Type == Ice::IceType_f64)
return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble());
- assert(0 && "Unexpected floating point type");
+ llvm_unreachable("Unexpected floating point type");
return NULL;
} else {
- assert(0 && "Unhandled constant type");
+ llvm_unreachable("Unhandled constant type");
return NULL;
}
} else {
@@ -534,7 +535,7 @@ private:
return Ice::InstAlloca::create(Func, ByteCount, Align, Dest);
}
- Ice::Inst *convertUnreachableInstruction(const UnreachableInst *Inst) {
+ Ice::Inst *convertUnreachableInstruction(const UnreachableInst * /*Inst*/) {
return Ice::InstUnreachable::create(Func);
}
@@ -576,12 +577,34 @@ static cl::list<Ice::VerboseItem> VerboseList(
clEnumValN(Ice::IceV_Timing, "time", "Pass timing details"),
clEnumValN(Ice::IceV_All, "all", "Use all verbose options"),
clEnumValN(Ice::IceV_None, "none", "No verbosity"), clEnumValEnd));
+static cl::opt<Ice::TargetArch> TargetArch(
+ "target", cl::desc("Target architecture:"), cl::init(Ice::Target_X8632),
+ cl::values(
+ clEnumValN(Ice::Target_X8632, "x8632", "x86-32"),
+ clEnumValN(Ice::Target_X8632, "x86-32", "x86-32 (same as x8632)"),
+ clEnumValN(Ice::Target_X8632, "x86_32", "x86-32 (same as x8632)"),
+ clEnumValN(Ice::Target_X8664, "x8664", "x86-64"),
+ clEnumValN(Ice::Target_X8664, "x86-64", "x86-64 (same as x8664)"),
+ clEnumValN(Ice::Target_X8664, "x86_64", "x86-64 (same as x8664)"),
+ clEnumValN(Ice::Target_ARM32, "arm", "arm32"),
+ clEnumValN(Ice::Target_ARM32, "arm32", "arm32 (same as arm)"),
+ clEnumValN(Ice::Target_ARM64, "arm64", "arm64"), clEnumValEnd));
+static cl::opt<Ice::OptLevel>
+OptLevel(cl::desc("Optimization level"), cl::init(Ice::Opt_m1),
+ cl::value_desc("level"),
+ cl::values(clEnumValN(Ice::Opt_m1, "Om1", "-1"),
+ clEnumValN(Ice::Opt_m1, "O-1", "-1"),
+ clEnumValN(Ice::Opt_0, "O0", "0"),
+ clEnumValN(Ice::Opt_0, "O1", "1"),
jvoung (off chromium) 2014/05/15 23:47:34 Should this be Opt_1 for O1?
Jim Stichnoth 2014/05/17 14:14:32 Done.
+ clEnumValN(Ice::Opt_2, "O2", "2"), clEnumValEnd));
static cl::opt<std::string> IRFilename(cl::Positional, cl::desc("<IR file>"),
cl::Required);
-static cl::opt<std::string> OutputFilename("o",
- cl::desc("Override output filename"),
+static cl::opt<std::string> OutputFilename("o", cl::desc("Set output filename"),
cl::init("-"),
cl::value_desc("filename"));
+static cl::opt<std::string> LogFilename("log", cl::desc("Set log filename"),
+ cl::init("-"),
+ cl::value_desc("filename"));
static cl::opt<std::string>
TestPrefix("prefix", cl::desc("Prepend a prefix to symbol names for testing"),
cl::init(""), cl::value_desc("prefix"));
@@ -627,8 +650,14 @@ int main(int argc, char **argv) {
raw_os_ostream *Os =
new raw_os_ostream(OutputFilename == "-" ? std::cout : Ofs);
Os->SetUnbuffered();
+ std::ofstream Lfs;
+ if (LogFilename != "-") {
+ Lfs.open(LogFilename.c_str(), std::ofstream::out);
+ }
+ raw_os_ostream *Ls = new raw_os_ostream(LogFilename == "-" ? std::cout : Lfs);
+ Ls->SetUnbuffered();
- Ice::GlobalContext Ctx(Os, Os, VMask, TestPrefix);
+ Ice::GlobalContext Ctx(Ls, Os, VMask, TargetArch, OptLevel, TestPrefix);
for (Module::const_iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) {
if (I->empty())
@@ -648,6 +677,25 @@ int main(int argc, char **argv) {
if (DisableTranslation) {
Func->dump();
+ } else {
+ Ice::Timer TTranslate;
+ Func->translate();
+ if (SubzeroTimingEnabled) {
+ std::cerr << "[Subzero timing] Translate function "
+ << Func->getFunctionName() << ": "
+ << TTranslate.getElapsedSec() << " sec\n";
+ }
+ if (Func->hasError()) {
+ errs() << "ICE translation error: " << Func->getError() << "\n";
jvoung (off chromium) 2014/05/19 20:28:54 Should this also toggle a flag that can help decid
Jim Stichnoth 2014/05/20 18:20:08 Done.
+ }
+
+ Ice::Timer TEmit;
+ Func->emit();
+ if (SubzeroTimingEnabled) {
+ std::cerr << "[Subzero timing] Emit function "
+ << Func->getFunctionName() << ": " << TEmit.getElapsedSec()
+ << " sec\n";
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698