From 9bb938c5401db90817d16b32fa078066fb586551 Mon Sep 17 00:00:00 2001 From: Jim Grosbach Date: Mon, 17 Sep 2012 18:00:53 +0000 Subject: TableGen: Add initializer. Keep GCC's warnings happy. It can't reason out that the state machine won't ever hit the potentially uninitialized use in OPC_FilterValue. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164041 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/FixedLenDecoderEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/TableGen/FixedLenDecoderEmitter.cpp') diff --git a/utils/TableGen/FixedLenDecoderEmitter.cpp b/utils/TableGen/FixedLenDecoderEmitter.cpp index aa6d796..e755c1c 100644 --- a/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -1882,7 +1882,7 @@ static void emitDecodeInstruction(formatted_raw_ostream &OS) { << " uint64_t Bits = STI.getFeatureBits();\n" << "\n" << " const uint8_t *Ptr = DecodeTable;\n" - << " uint32_t CurFieldValue;\n" + << " uint32_t CurFieldValue = 0;\n" << " DecodeStatus S = MCDisassembler::Success;\n" << " for (;;) {\n" << " ptrdiff_t Loc = Ptr - DecodeTable;\n" -- cgit v1.1 From 736ceace11249da645ec4ed91b8714832193ead4 Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Fri, 5 Oct 2012 03:31:58 +0000 Subject: tblgen: Replace uses of dynamic_cast with dyn_cast<>. This is a mechanical change of dynamic_cast<> to dyn_cast<>. A number of these uses are actually more like isa<> or cast<>, and will be changed to the semanticaly appropriate one in a future patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165291 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/FixedLenDecoderEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/TableGen/FixedLenDecoderEmitter.cpp') diff --git a/utils/TableGen/FixedLenDecoderEmitter.cpp b/utils/TableGen/FixedLenDecoderEmitter.cpp index e755c1c..b5f62d8 100644 --- a/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -1758,7 +1758,7 @@ static bool populateInstruction(const CodeGenInstruction &CGI, unsigned Opc, // FIXME: This need to be extended to handle instructions with custom // decoder methods, and operands with (simple) MIOperandInfo's. TypedInit *TI = dynamic_cast(NI->first); - RecordRecTy *Type = dynamic_cast(TI->getType()); + RecordRecTy *Type = dyn_cast(TI->getType()); Record *TypeRecord = Type->getRecord(); bool isReg = false; if (TypeRecord->isSubClassOf("RegisterOperand")) -- cgit v1.1 From 6cfc806a6b82b60a3e923b6b89f2b4da62cdb50b Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Wed, 10 Oct 2012 20:24:43 +0000 Subject: tblgen: Mechanically move dynamic_cast<> to dyn_cast<>. Some of these dyn_cast<>'s would be better phrased as isa<> or cast<>. That will happen in a future patch. There are also two dyn_cast_or_null<>'s slipped in instead of dyn_cast<>'s, since they were causing crashes with just dyn_cast<>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165646 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/FixedLenDecoderEmitter.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'utils/TableGen/FixedLenDecoderEmitter.cpp') diff --git a/utils/TableGen/FixedLenDecoderEmitter.cpp b/utils/TableGen/FixedLenDecoderEmitter.cpp index b5f62d8..aa4dd8a 100644 --- a/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -142,7 +142,7 @@ 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 (BitInit *bit = dynamic_cast(bits.getBit(index))) + if (BitInit *bit = dyn_cast(bits.getBit(index))) return bit->getValue() ? BIT_TRUE : BIT_FALSE; // The bit is uninitialized. @@ -1757,7 +1757,7 @@ static bool populateInstruction(const CodeGenInstruction &CGI, unsigned Opc, // for decoding register classes. // FIXME: This need to be extended to handle instructions with custom // decoder methods, and operands with (simple) MIOperandInfo's. - TypedInit *TI = dynamic_cast(NI->first); + TypedInit *TI = dyn_cast(NI->first); RecordRecTy *Type = dyn_cast(TI->getType()); Record *TypeRecord = Type->getRecord(); bool isReg = false; @@ -1770,7 +1770,7 @@ static bool populateInstruction(const CodeGenInstruction &CGI, unsigned Opc, RecordVal *DecoderString = TypeRecord->getValue("DecoderMethod"); StringInit *String = DecoderString ? - dynamic_cast(DecoderString->getValue()) : 0; + dyn_cast(DecoderString->getValue()) : 0; if (!isReg && String && String->getValue() != "") Decoder = String->getValue(); @@ -1781,11 +1781,11 @@ static bool populateInstruction(const CodeGenInstruction &CGI, unsigned Opc, for (unsigned bi = 0; bi < Bits.getNumBits(); ++bi) { VarInit *Var = 0; - VarBitInit *BI = dynamic_cast(Bits.getBit(bi)); + VarBitInit *BI = dyn_cast(Bits.getBit(bi)); if (BI) - Var = dynamic_cast(BI->getBitVar()); + Var = dyn_cast(BI->getBitVar()); else - Var = dynamic_cast(Bits.getBit(bi)); + Var = dyn_cast(Bits.getBit(bi)); if (!Var) { if (Base != ~0U) { -- cgit v1.1 From 3f7b7f8ce0b050fc6a0100839d9c5a84198b2aed Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Wed, 10 Oct 2012 20:24:47 +0000 Subject: tblgen: Use semantically correct RTTI functions. Also, some minor cleanup. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165647 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/FixedLenDecoderEmitter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'utils/TableGen/FixedLenDecoderEmitter.cpp') diff --git a/utils/TableGen/FixedLenDecoderEmitter.cpp b/utils/TableGen/FixedLenDecoderEmitter.cpp index aa4dd8a..c53776b 100644 --- a/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -1757,8 +1757,8 @@ static bool populateInstruction(const CodeGenInstruction &CGI, unsigned Opc, // for decoding register classes. // FIXME: This need to be extended to handle instructions with custom // decoder methods, and operands with (simple) MIOperandInfo's. - TypedInit *TI = dyn_cast(NI->first); - RecordRecTy *Type = dyn_cast(TI->getType()); + TypedInit *TI = cast(NI->first); + RecordRecTy *Type = cast(TI->getType()); Record *TypeRecord = Type->getRecord(); bool isReg = false; if (TypeRecord->isSubClassOf("RegisterOperand")) -- cgit v1.1 From 61131ab15fd593a2e295d79fe2714e7bc21f2ec8 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Thu, 25 Oct 2012 20:33:17 +0000 Subject: Remove exception handling usage from tblgen. Most places can use PrintFatalError as the unwinding mechanism was not used for anything other than printing the error. The single exception was CodeGenDAGPatterns.cpp, where intermediate errors during type resolution were ignored to simplify incremental platform development. This use is replaced by an error flag in TreePattern and bailout earlier in various places if it is set. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166712 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/FixedLenDecoderEmitter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'utils/TableGen/FixedLenDecoderEmitter.cpp') diff --git a/utils/TableGen/FixedLenDecoderEmitter.cpp b/utils/TableGen/FixedLenDecoderEmitter.cpp index c53776b..5cabcad 100644 --- a/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -15,6 +15,7 @@ #define DEBUG_TYPE "decoder-emitter" #include "CodeGenTarget.h" +#include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" #include "llvm/ADT/APInt.h" #include "llvm/ADT/SmallString.h" @@ -741,7 +742,7 @@ void FixedLenDecoderEmitter::emitTable(formatted_raw_ostream &OS, switch (*I) { default: - throw "invalid decode table opcode"; + PrintFatalError("invalid decode table opcode"); case MCD::OPC_ExtractField: { ++I; unsigned Start = *I++; -- cgit v1.1 From 4ffd89fa4d2788611187d1a534d2ed46adf1702c Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Tue, 4 Dec 2012 10:37:14 +0000 Subject: Sort the #include lines for utils/... I've tried to find main moudle headers where possible, but the TableGen stuff may warrant someone else looking at it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169251 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/FixedLenDecoderEmitter.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'utils/TableGen/FixedLenDecoderEmitter.cpp') diff --git a/utils/TableGen/FixedLenDecoderEmitter.cpp b/utils/TableGen/FixedLenDecoderEmitter.cpp index 5cabcad..b2dc878 100644 --- a/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -15,8 +15,6 @@ #define DEBUG_TYPE "decoder-emitter" #include "CodeGenTarget.h" -#include "llvm/TableGen/Error.h" -#include "llvm/TableGen/Record.h" #include "llvm/ADT/APInt.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" @@ -28,11 +26,12 @@ #include "llvm/Support/FormattedStream.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/TableGen/Error.h" +#include "llvm/TableGen/Record.h" #include "llvm/TableGen/TableGenBackend.h" - -#include #include #include +#include using namespace llvm; -- cgit v1.1 From fc093def2d892a2ea068d3b9e6d5839c187cc942 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 26 Dec 2012 06:43:14 +0000 Subject: TableGen/FixedLenDecoderEmitter.cpp: Fix a potential mask overflow in fieldFromInstruction(). Reported by Yang Yongyong, thanks! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171101 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/FixedLenDecoderEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/TableGen/FixedLenDecoderEmitter.cpp') diff --git a/utils/TableGen/FixedLenDecoderEmitter.cpp b/utils/TableGen/FixedLenDecoderEmitter.cpp index b2dc878..0c3017f 100644 --- a/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -1866,7 +1866,7 @@ static void emitFieldFromInstruction(formatted_raw_ostream &OS) { << " if (numBits == sizeof(InsnType)*8)\n" << " fieldMask = (InsnType)(-1LL);\n" << " else\n" - << " fieldMask = ((1 << numBits) - 1) << startBit;\n" + << " fieldMask = (((InsnType)1 << numBits) - 1) << startBit;\n" << " return (insn & fieldMask) >> startBit;\n" << "}\n\n"; } -- cgit v1.1