summaryrefslogtreecommitdiff
path: root/compiler/driver/compiler_options.cc
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2016-08-06 02:41:24 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-08-06 02:41:24 +0000
commit1568ed9bd7e8fda112bc3afcf6d139637f2c65ce (patch)
tree84f69ce45c614a0c015109cfa655f298a6463e3b /compiler/driver/compiler_options.cc
parent95a976a3d1842384ed71bcc6e6449de95ec69961 (diff)
parent2cd05b7d9976c0c7fa74d58cb1608c809e5c37d3 (diff)
Merge "Add a register allocation strategy compiler option"
Diffstat (limited to 'compiler/driver/compiler_options.cc')
-rw-r--r--compiler/driver/compiler_options.cc24
1 files changed, 21 insertions, 3 deletions
diff --git a/compiler/driver/compiler_options.cc b/compiler/driver/compiler_options.cc
index f20dba34a6..a522e0c7b5 100644
--- a/compiler/driver/compiler_options.cc
+++ b/compiler/driver/compiler_options.cc
@@ -44,7 +44,8 @@ CompilerOptions::CompilerOptions()
init_failure_output_(nullptr),
dump_cfg_file_name_(""),
dump_cfg_append_(false),
- force_determinism_(false) {
+ force_determinism_(false),
+ register_allocation_strategy_(RegisterAllocator::kRegisterAllocatorDefault) {
}
CompilerOptions::~CompilerOptions() {
@@ -74,7 +75,8 @@ CompilerOptions::CompilerOptions(CompilerFilter::Filter compiler_filter,
bool abort_on_hard_verifier_failure,
const std::string& dump_cfg_file_name,
bool dump_cfg_append,
- bool force_determinism
+ bool force_determinism,
+ RegisterAllocator::Strategy regalloc_strategy
) : // NOLINT(whitespace/parens)
compiler_filter_(compiler_filter),
huge_method_threshold_(huge_method_threshold),
@@ -99,7 +101,8 @@ CompilerOptions::CompilerOptions(CompilerFilter::Filter compiler_filter,
init_failure_output_(init_failure_output),
dump_cfg_file_name_(dump_cfg_file_name),
dump_cfg_append_(dump_cfg_append),
- force_determinism_(force_determinism) {
+ force_determinism_(force_determinism),
+ register_allocation_strategy_(regalloc_strategy) {
}
void CompilerOptions::ParseHugeMethodMax(const StringPiece& option, UsageFn Usage) {
@@ -144,6 +147,19 @@ void CompilerOptions::ParseDumpInitFailures(const StringPiece& option,
}
}
+void CompilerOptions::ParseRegisterAllocationStrategy(const StringPiece& option,
+ UsageFn Usage) {
+ DCHECK(option.starts_with("--register-allocation-strategy="));
+ StringPiece choice = option.substr(strlen("--register-allocation-strategy=")).data();
+ if (choice == "linear-scan") {
+ register_allocation_strategy_ = RegisterAllocator::Strategy::kRegisterAllocatorLinearScan;
+ } else if (choice == "graph-color") {
+ register_allocation_strategy_ = RegisterAllocator::Strategy::kRegisterAllocatorGraphColor;
+ } else {
+ Usage("Unrecognized register allocation strategy. Try linear-scan, or graph-color.");
+ }
+}
+
bool CompilerOptions::ParseCompilerOption(const StringPiece& option, UsageFn Usage) {
if (option.starts_with("--compiler-filter=")) {
const char* compiler_filter_string = option.substr(strlen("--compiler-filter=")).data();
@@ -190,6 +206,8 @@ bool CompilerOptions::ParseCompilerOption(const StringPiece& option, UsageFn Usa
dump_cfg_file_name_ = option.substr(strlen("--dump-cfg=")).data();
} else if (option.starts_with("--dump-cfg-append")) {
dump_cfg_append_ = true;
+ } else if (option.starts_with("--register-allocation-strategy=")) {
+ ParseRegisterAllocationStrategy(option, Usage);
} else {
// Option not recognized.
return false;