MC: Constify MCAsmLayout argument to MCExpr::EvaluteAs...
authorDaniel Dunbar <daniel@zuster.org>
Fri, 12 Mar 2010 21:00:45 +0000 (21:00 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 12 Mar 2010 21:00:45 +0000 (21:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98380 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCAsmLayout.h
include/llvm/MC/MCAssembler.h
include/llvm/MC/MCExpr.h
lib/MC/MCExpr.cpp
lib/Target/X86/X86MCTargetExpr.cpp
lib/Target/X86/X86MCTargetExpr.h

index d448625320cd99aa759b9dc2a1c2426e8de8288e..27bdbe9cbf599cbc246b72afe0bf1324a94151a5 100644 (file)
@@ -28,7 +28,7 @@ public:
   MCAsmLayout(MCAssembler &_Assembler) : Assembler(_Assembler) {}
 
   /// Get the assembler object this is a layout for.
-  MCAssembler &getAssembler() { return Assembler; }
+  MCAssembler &getAssembler() const { return Assembler; }
 };
 
 } // end namespace llvm
index f0efb6ce4a27f6711afebc4d92d18323930a9969..4db1c012b08c72d4cf445385cfde2c69da2e92ad 100644 (file)
@@ -204,7 +204,8 @@ class MCAlignFragment : public MCFragment {
   /// cannot be satisfied in this width then this fragment is ignored.
   unsigned MaxBytesToEmit;
 
-  /// EmitNops - true when aligning code and optimal nops to be used for filling
+  /// EmitNops - true when aligning code and optimal nops to be used for
+  /// filling.
   bool EmitNops;
 
 public:
@@ -704,8 +705,8 @@ public:
   /// @name Backend Data Access
   /// @{
 
-  MCSectionData &getSectionData(const MCSection &Section) {
-    MCSectionData *&Entry = SectionMap[&Section];
+  MCSectionData &getSectionData(const MCSection &Section) const {
+    MCSectionData *Entry = SectionMap.lookup(&Section);
     assert(Entry && "Missing section data!");
     return *Entry;
   }
@@ -721,8 +722,8 @@ public:
     return *Entry;
   }
 
-  MCSymbolData &getSymbolData(const MCSymbol &Symbol) {
-    MCSymbolData *&Entry = SymbolMap[&Symbol];
+  MCSymbolData &getSymbolData(const MCSymbol &Symbol) const {
+    MCSymbolData *Entry = SymbolMap.lookup(&Symbol);
     assert(Entry && "Missing symbol data!");
     return *Entry;
   }
index 9daddb2923d5806f351fafcfd9fa5be3c2557378..5f8163f19e4ec50de935d76d900aa37c76f230ea 100644 (file)
@@ -67,7 +67,7 @@ public:
   /// values. If not given, then only non-symbolic expressions will be
   /// evaluated.
   /// @result - True on success.
-  bool EvaluateAsAbsolute(int64_t &Res, MCAsmLayout *Layout = 0) const;
+  bool EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout *Layout = 0) const;
 
   /// EvaluateAsRelocatable - Try to evaluate the expression to a relocatable
   /// value, i.e. an expression of the fixed form (a - b + constant).
@@ -75,13 +75,13 @@ public:
   /// @param Res - The relocatable value, if evaluation succeeds.
   /// @param Layout - The assembler layout object to use for evaluating values.
   /// @result - True on success.
-  bool EvaluateAsRelocatable(MCValue &Res, MCAsmLayout *Layout = 0) const;
+  bool EvaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout = 0) const;
 
   /// @}
 
   static bool classof(const MCExpr *) { return true; }
 };
-  
+
 inline raw_ostream &operator<<(raw_ostream &OS, const MCExpr &E) {
   E.print(OS);
   return OS;
@@ -351,12 +351,12 @@ protected:
   MCTargetExpr() : MCExpr(Target) {}
   virtual ~MCTargetExpr() {}
 public:
-  
+
   virtual void PrintImpl(raw_ostream &OS) const = 0;
   virtual bool EvaluateAsRelocatableImpl(MCValue &Res,
-                                         MCAsmLayout *Layout) const = 0;
+                                         const MCAsmLayout *Layout) const = 0;
+
 
-  
   static bool classof(const MCExpr *E) {
     return E->getKind() == MCExpr::Target;
   }
index 0ca2ad8761b94e2440b84a18bf95e9cab1106268..8d84f53037dc368716f6ec2a67b1e096a0a71c74 100644 (file)
@@ -145,7 +145,7 @@ void MCTargetExpr::Anchor() {}
 
 /* *** */
 
-bool MCExpr::EvaluateAsAbsolute(int64_t &Res, MCAsmLayout *Layout) const {
+bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout *Layout) const {
   MCValue Value;
   
   if (!EvaluateAsRelocatable(Value, Layout) || !Value.isAbsolute())
@@ -177,7 +177,8 @@ static bool EvaluateSymbolicAdd(const MCValue &LHS, const MCSymbol *RHS_A,
   return true;
 }
 
-bool MCExpr::EvaluateAsRelocatable(MCValue &Res, MCAsmLayout *Layout) const {
+bool MCExpr::EvaluateAsRelocatable(MCValue &Res,
+                                   const MCAsmLayout *Layout) const {
   switch (getKind()) {
   case Target:
     return cast<MCTargetExpr>(this)->EvaluateAsRelocatableImpl(Res, Layout);
index de56d3130766e4bf085150a86baa5f15a184b9ac..cfcf70221d1869a9b73c05e17c63e273dca38e47 100644 (file)
@@ -37,7 +37,7 @@ void X86MCTargetExpr::PrintImpl(raw_ostream &OS) const {
 }
 
 bool X86MCTargetExpr::EvaluateAsRelocatableImpl(MCValue &Res,
-                                                MCAsmLayout *Layout) const {
+                                              const MCAsmLayout *Layout) const {
   // FIXME: I don't know if this is right, it followed MCSymbolRefExpr.
   
   // Evaluate recursively if this is a variable.
index 56011eb053f7619498d469fd732718789d7179f1..a82e142a07fc0f1eebdc88bad10f55dc081036a2 100644 (file)
@@ -41,7 +41,7 @@ public:
                                  MCContext &Ctx);
   
   void PrintImpl(raw_ostream &OS) const;
-  bool EvaluateAsRelocatableImpl(MCValue &Res, MCAsmLayout *Layout) const;
+  bool EvaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout) const;
 };
   
 } // end namespace llvm