[llvm] r201689 - [mips] Use llvm::Triple in ParseMipsTriple() instead of manually parsing it

Daniel Sanders daniel.sanders at imgtec.com
Wed Feb 19 07:55:21 PST 2014


Author: dsanders
Date: Wed Feb 19 09:55:21 2014
New Revision: 201689

URL: http://llvm.org/viewvc/llvm-project?rev=201689&view=rev
Log:
[mips] Use llvm::Triple in ParseMipsTriple() instead of manually parsing it

No functional change.


Modified:
    llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp

Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp?rev=201689&r1=201688&r2=201689&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp Wed Feb 19 09:55:21 2014
@@ -15,6 +15,7 @@
 #include "InstPrinter/MipsInstPrinter.h"
 #include "MipsMCAsmInfo.h"
 #include "MipsTargetStreamer.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/MC/MCCodeGenInfo.h"
 #include "llvm/MC/MCELFStreamer.h"
 #include "llvm/MC/MCInstrInfo.h"
@@ -40,21 +41,10 @@ using namespace llvm;
 
 static std::string ParseMipsTriple(StringRef TT, StringRef CPU) {
   std::string MipsArchFeature;
-  size_t DashPosition = 0;
-  StringRef TheTriple;
+  Triple TheTriple(TT);
 
-  // Let's see if there is a dash, like mips-unknown-linux.
-  DashPosition = TT.find('-');
-
-  if (DashPosition == StringRef::npos) {
-    // No dash, we check the string size.
-    TheTriple = TT.substr(0);
-  } else {
-    // We are only interested in substring before dash.
-    TheTriple = TT.substr(0,DashPosition);
-  }
-
-  if (TheTriple == "mips" || TheTriple == "mipsel") {
+  if (TheTriple.getArch() == Triple::mips ||
+      TheTriple.getArch() == Triple::mipsel) {
     if (CPU.empty() || CPU == "mips32") {
       MipsArchFeature = "+mips32";
     } else if (CPU == "mips32r2") {





More information about the llvm-commits mailing list