diff --git a/utils/TableGen/FixedLenDecoderEmitter.cpp b/utils/TableGen/FixedLenDecoderEmitter.cpp
index e4b6f12..c9dcb01 100644
--- a/utils/TableGen/FixedLenDecoderEmitter.cpp
+++ b/utils/TableGen/FixedLenDecoderEmitter.cpp
@@ -48,15 +48,15 @@
 static int Value(bit_value_t V) {
   return ValueNotSet(V) ? -1 : (V == BIT_FALSE ? 0 : 1);
 }
-static bit_value_t bitFromBits(const BitsInit &bits, unsigned index) {
-  if (const BitInit *bit = dynamic_cast<const BitInit*>(bits.getBit(index)))
+static bit_value_t bitFromBits(BitsInit &bits, unsigned index) {
+  if (BitInit *bit = dynamic_cast<BitInit*>(bits.getBit(index)))
     return bit->getValue() ? BIT_TRUE : BIT_FALSE;
 
   // The bit is uninitialized.
   return BIT_UNSET;
 }
 // Prints the bit value for each position.
-static void dumpBits(raw_ostream &o, const BitsInit &bits) {
+static void dumpBits(raw_ostream &o, BitsInit &bits) {
   unsigned index;
 
   for (index = bits.getNumBits(); index > 0; index--) {
@@ -76,8 +76,8 @@
   }
 }
 
-static const BitsInit &getBitsField(const Record &def, const char *str) {
-  const BitsInit *bits = def.getValueAsBitsInit(str);
+static BitsInit &getBitsField(const Record &def, const char *str) {
+  BitsInit *bits = def.getValueAsBitsInit(str);
   return *bits;
 }
 
@@ -279,8 +279,7 @@
 protected:
   // Populates the insn given the uid.
   void insnWithID(insn_t &Insn, unsigned Opcode) const {
-    const BitsInit &Bits =
-      getBitsField(*AllInstructions[Opcode]->TheDef, "Inst");
+    BitsInit &Bits = getBitsField(*AllInstructions[Opcode]->TheDef, "Inst");
 
     for (unsigned i = 0; i < BIT_WIDTH; ++i)
       Insn[i] = bitFromBits(Bits, i);
@@ -1231,7 +1230,7 @@
       Def.getValueAsBit("isCodeGenOnly"))
     return false;
 
-  const BitsInit &Bits = getBitsField(Def, "Inst");
+  BitsInit &Bits = getBitsField(Def, "Inst");
   if (Bits.allInComplete()) return false;
 
   std::vector<OperandInfo> InsnOperands;
@@ -1252,16 +1251,16 @@
   // Gather the outputs/inputs of the instruction, so we can find their
   // positions in the encoding.  This assumes for now that they appear in the
   // MCInst in the order that they're listed.
-  std::vector<std::pair<const Init*, std::string> > InOutOperands;
-  const DagInit *Out = Def.getValueAsDag("OutOperandList");
-  const DagInit *In  = Def.getValueAsDag("InOperandList");
+  std::vector<std::pair<Init*, std::string> > InOutOperands;
+  DagInit *Out  = Def.getValueAsDag("OutOperandList");
+  DagInit *In  = Def.getValueAsDag("InOperandList");
   for (unsigned i = 0; i < Out->getNumArgs(); ++i)
     InOutOperands.push_back(std::make_pair(Out->getArg(i), Out->getArgName(i)));
   for (unsigned i = 0; i < In->getNumArgs(); ++i)
     InOutOperands.push_back(std::make_pair(In->getArg(i), In->getArgName(i)));
 
   // For each operand, see if we can figure out where it is encoded.
-  for (std::vector<std::pair<const Init*, std::string> >::iterator
+  for (std::vector<std::pair<Init*, std::string> >::iterator
        NI = InOutOperands.begin(), NE = InOutOperands.end(); NI != NE; ++NI) {
     unsigned PrevBit = ~0;
     unsigned Base = ~0;
@@ -1269,10 +1268,10 @@
     std::string Decoder = "";
 
     for (unsigned bi = 0; bi < Bits.getNumBits(); ++bi) {
-      const VarBitInit *BI = dynamic_cast<const VarBitInit*>(Bits.getBit(bi));
+      VarBitInit *BI = dynamic_cast<VarBitInit*>(Bits.getBit(bi));
       if (!BI) continue;
 
-      const VarInit *Var = dynamic_cast<const VarInit*>(BI->getVariable());
+      VarInit *Var = dynamic_cast<VarInit*>(BI->getVariable());
       assert(Var);
       unsigned CurrBit = BI->getBitNum();
       if (Var->getName() != NI->second) continue;
@@ -1302,7 +1301,7 @@
       // for decoding register classes.
       // FIXME: This need to be extended to handle instructions with custom
       // decoder methods, and operands with (simple) MIOperandInfo's.
-      const TypedInit *TI = dynamic_cast<const TypedInit*>(NI->first);
+      TypedInit *TI = dynamic_cast<TypedInit*>(NI->first);
       RecordRecTy *Type = dynamic_cast<RecordRecTy*>(TI->getType());
       Record *TypeRecord = Type->getRecord();
       bool isReg = false;
@@ -1314,8 +1313,8 @@
       }
 
       RecordVal *DecoderString = TypeRecord->getValue("DecoderMethod");
-      const StringInit *String = DecoderString ?
-        dynamic_cast<const StringInit*>(DecoderString->getValue()) :
+      StringInit *String = DecoderString ?
+        dynamic_cast<StringInit*>(DecoderString->getValue()) :
         0;
       if (!isReg && String && String->getValue() != "")
         Decoder = String->getValue();
