about summary refs log tree commit diff
path: root/src/rustllvm/PassWrapper.cpp
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-05-07 03:34:27 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-05-16 12:02:11 +0300
commit55a94bdc384673fe2ae7bc2b0275a5777c830b52 (patch)
tree7cf607ed4fb88b5567062df75e93fc9bdef8e922 /src/rustllvm/PassWrapper.cpp
parent84539360498cab3c70a7c9114c0b8106c8e1b06b (diff)
downloadrust-55a94bdc384673fe2ae7bc2b0275a5777c830b52.tar.gz
rust-55a94bdc384673fe2ae7bc2b0275a5777c830b52.zip
rustc_target: Stop using "string typing" for code models
Introduce `enum CodeModel` instead.
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
-rw-r--r--src/rustllvm/PassWrapper.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
index 84bde9a52f7..e7cd81ea68e 100644
--- a/src/rustllvm/PassWrapper.cpp
+++ b/src/rustllvm/PassWrapper.cpp
@@ -274,7 +274,7 @@ extern "C" bool LLVMRustHasFeature(LLVMTargetMachineRef TM,
 }
 
 enum class LLVMRustCodeModel {
-  Other,
+  Tiny,
   Small,
   Kernel,
   Medium,
@@ -282,8 +282,10 @@ enum class LLVMRustCodeModel {
   None,
 };
 
-static CodeModel::Model fromRust(LLVMRustCodeModel Model) {
+static Optional<CodeModel::Model> fromRust(LLVMRustCodeModel Model) {
   switch (Model) {
+  case LLVMRustCodeModel::Tiny:
+    return CodeModel::Tiny;
   case LLVMRustCodeModel::Small:
     return CodeModel::Small;
   case LLVMRustCodeModel::Kernel:
@@ -292,6 +294,8 @@ static CodeModel::Model fromRust(LLVMRustCodeModel Model) {
     return CodeModel::Medium;
   case LLVMRustCodeModel::Large:
     return CodeModel::Large;
+  case LLVMRustCodeModel::None:
+    return None;
   default:
     report_fatal_error("Bad CodeModel.");
   }
@@ -452,6 +456,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
 
   auto OptLevel = fromRust(RustOptLevel);
   auto RM = fromRust(RustReloc);
+  auto CM = fromRust(RustCM);
 
   std::string Error;
   Triple Trip(Triple::normalize(TripleStr));
@@ -490,9 +495,6 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
 
   Options.EmitStackSizeSection = EmitStackSizeSection;
 
-  Optional<CodeModel::Model> CM;
-  if (RustCM != LLVMRustCodeModel::None)
-    CM = fromRust(RustCM);
   TargetMachine *TM = TheTarget->createTargetMachine(
       Trip.getTriple(), CPU, Feature, Options, RM, CM, OptLevel);
   return wrap(TM);