From: Craig Topper Date: Sat, 6 Jun 2015 01:34:04 +0000 (+0000) Subject: [TableGen] Change OpInit::getNumOperands and getOperand to use unsigned integers... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=d032911655e41bd46b0a73b0d1205f3fffc6955f [TableGen] Change OpInit::getNumOperands and getOperand to use unsigned integers. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239210 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/TableGen/Record.h b/include/llvm/TableGen/Record.h index ecf9ea7b70a..770eb3b8e2e 100644 --- a/include/llvm/TableGen/Record.h +++ b/include/llvm/TableGen/Record.h @@ -660,8 +660,8 @@ public: // Clone - Clone this operator, replacing arguments with the new list virtual OpInit *clone(std::vector &Operands) const = 0; - virtual int getNumOperands() const = 0; - virtual Init *getOperand(int i) const = 0; + virtual unsigned getNumOperands() const = 0; + virtual Init *getOperand(unsigned i) const = 0; // Fold - If possible, fold this to a simpler init. Return this if not // possible to fold. @@ -702,8 +702,8 @@ public: return UnOpInit::get(getOpcode(), *Operands.begin(), getType()); } - int getNumOperands() const override { return 1; } - Init *getOperand(int i) const override { + unsigned getNumOperands() const override { return 1; } + Init *getOperand(unsigned i) const override { assert(i == 0 && "Invalid operand id for unary operator"); return getOperand(); } @@ -750,8 +750,8 @@ public: return BinOpInit::get(getOpcode(), Operands[0], Operands[1], getType()); } - int getNumOperands() const override { return 2; } - Init *getOperand(int i) const override { + unsigned getNumOperands() const override { return 2; } + Init *getOperand(unsigned i) const override { switch (i) { default: llvm_unreachable("Invalid operand id for binary operator"); case 0: return getLHS(); @@ -805,8 +805,8 @@ public: getType()); } - int getNumOperands() const override { return 3; } - Init *getOperand(int i) const override { + unsigned getNumOperands() const override { return 3; } + Init *getOperand(unsigned i) const override { switch (i) { default: llvm_unreachable("Invalid operand id for ternary operator"); case 0: return getLHS(); diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index 00f022b98c6..97e796c1349 100644 --- a/lib/TableGen/Record.cpp +++ b/lib/TableGen/Record.cpp @@ -891,7 +891,7 @@ static Init *EvaluateOperation(OpInit *RHSo, Init *LHS, Init *Arg, return ForeachHelper(LHS, Arg, RHSo, Type, CurRec, CurMultiClass); std::vector NewOperands; - for (int i = 0; i < RHSo->getNumOperands(); ++i) { + for (unsigned i = 0; i < RHSo->getNumOperands(); ++i) { if (auto *RHSoo = dyn_cast(RHSo->getOperand(i))) { if (Init *Result = EvaluateOperation(RHSoo, LHS, Arg, Type, CurRec, CurMultiClass)) @@ -955,7 +955,7 @@ static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, for (Init *&Item : NewList) { NewOperands.clear(); - for(int i = 0; i < RHSo->getNumOperands(); ++i) { + for(unsigned i = 0; i < RHSo->getNumOperands(); ++i) { // First, replace the foreach variable with the list item if (LHS->getAsString() == RHSo->getOperand(i)->getAsString()) NewOperands.push_back(Item);