[llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h MachineInstrBuilder.h

Chris Lattner lattner at cs.uiuc.edu
Fri Nov 19 12:46:31 PST 2004



Changes in directory llvm/include/llvm/CodeGen:

MachineInstr.h updated: 1.157 -> 1.158
MachineInstrBuilder.h updated: 1.24 -> 1.25
---
Log message:

Instead of storing std::string's for ExternalSymbol references, rely on the
fact that all ExternalSymbols are actually string literals with static storage.
Thus we don't have to do anything special to hold them and we certainly don't
have to copy string data around.


---
Diffs of the changes:  (+9 -19)

Index: llvm/include/llvm/CodeGen/MachineInstr.h
diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.157 llvm/include/llvm/CodeGen/MachineInstr.h:1.158
--- llvm/include/llvm/CodeGen/MachineInstr.h:1.157	Wed Oct 27 11:14:51 2004
+++ llvm/include/llvm/CodeGen/MachineInstr.h	Fri Nov 19 14:46:15 2004
@@ -17,7 +17,6 @@
 #define LLVM_CODEGEN_MACHINEINSTR_H
 
 #include "llvm/ADT/iterator"
-#include <string>
 #include <vector>
 #include <cassert>
 
@@ -121,7 +120,7 @@
     int immedVal;		// Constant value for an explicit constant
 
     MachineBasicBlock *MBB;     // For MO_MachineBasicBlock type
-    std::string *SymbolName;    // For MO_ExternalSymbol type
+    const char *SymbolName;     // For MO_ExternalSymbol type
   } contents;
 
   char flags;                   // see bit field definitions above
@@ -177,10 +176,10 @@
     extra.regNum = -1;
   }
 
-  MachineOperand(const std::string &SymName, bool isPCRelative, int Offset)
+  MachineOperand(const char *SymName, bool isPCRelative, int Offset)
     : flags(isPCRelative?PCRELATIVE:0), opType(MO_ExternalSymbol) {
     zeroContents ();
-    contents.SymbolName = new std::string (SymName);
+    contents.SymbolName = SymName;
     extra.offset = Offset;
   }
 
@@ -190,25 +189,16 @@
     zeroContents ();
     contents = M.contents;
     extra = M.extra;
-    if (isExternalSymbol())
-      contents.SymbolName = new std::string(M.getSymbolName());
   }
 
  
-  ~MachineOperand() {
-    if (isExternalSymbol())
-      delete contents.SymbolName;
-  }
+  ~MachineOperand() {}
   
   const MachineOperand &operator=(const MachineOperand &MO) {
-    if (isExternalSymbol())             // if old operand had a symbol name,
-      delete contents.SymbolName;       // release old memory
     contents = MO.contents;
     flags    = MO.flags;
     opType   = MO.opType;
     extra    = MO.extra;
-    if (isExternalSymbol())
-      contents.SymbolName = new std::string(MO.getSymbolName());
     return *this;
   }
 
@@ -298,9 +288,9 @@
         "Wrong MachineOperand accessor");
     return extra.offset;
   }
-  const std::string &getSymbolName() const {
+  const char *getSymbolName() const {
     assert(isExternalSymbol() && "Wrong MachineOperand accessor");
-    return *contents.SymbolName;
+    return contents.SymbolName;
   }
 
   /// MachineOperand methods for testing that work on any kind of
@@ -658,7 +648,7 @@
 
   /// addExternalSymbolOperand - Add an external symbol operand to this instr
   ///
-  void addExternalSymbolOperand(const std::string &SymName, bool isPCRelative) {
+  void addExternalSymbolOperand(const char *SymName, bool isPCRelative) {
     operands.push_back(MachineOperand(SymName, isPCRelative, 0));
   }
 


Index: llvm/include/llvm/CodeGen/MachineInstrBuilder.h
diff -u llvm/include/llvm/CodeGen/MachineInstrBuilder.h:1.24 llvm/include/llvm/CodeGen/MachineInstrBuilder.h:1.25
--- llvm/include/llvm/CodeGen/MachineInstrBuilder.h:1.24	Thu Oct 14 23:38:36 2004
+++ llvm/include/llvm/CodeGen/MachineInstrBuilder.h	Fri Nov 19 14:46:15 2004
@@ -129,9 +129,9 @@
     return *this;
   }
 
-  const MachineInstrBuilder &addExternalSymbol(const std::string &Name,
+  const MachineInstrBuilder &addExternalSymbol(const char *FnName,
                                                bool isPCRelative = false) const{
-    MI->addExternalSymbolOperand(Name, isPCRelative);
+    MI->addExternalSymbolOperand(FnName, isPCRelative);
     return *this;
   }
 };






More information about the llvm-commits mailing list