mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-24 08:24:33 +00:00
Moved getBinaryOperator to the BinaryOperator class and the getUnaryOperator
to the UnaryOperator class (from the Instruction class). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -56,13 +56,19 @@ public:
|
|||||||
class UnaryOperator : public Instruction {
|
class UnaryOperator : public Instruction {
|
||||||
Use Source;
|
Use Source;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// getUnaryOperator() - Construct a unary instruction, given the opcode
|
||||||
|
// and its operand.
|
||||||
|
//
|
||||||
|
static UnaryOperator *getUnaryOperator(unsigned Op, Value *Source);
|
||||||
|
|
||||||
UnaryOperator(Value *S, unsigned iType, const string &Name = "")
|
UnaryOperator(Value *S, unsigned iType, const string &Name = "")
|
||||||
: Instruction(S->getType(), iType, Name), Source(S, this) {
|
: Instruction(S->getType(), iType, Name), Source(S, this) {
|
||||||
}
|
}
|
||||||
inline ~UnaryOperator() { dropAllReferences(); }
|
inline ~UnaryOperator() { dropAllReferences(); }
|
||||||
|
|
||||||
virtual Instruction *clone() const {
|
virtual Instruction *clone() const {
|
||||||
return Instruction::getUnaryOperator(getInstType(), Source);
|
return getUnaryOperator(getInstType(), Source);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void dropAllReferences() {
|
virtual void dropAllReferences() {
|
||||||
@ -92,6 +98,12 @@ public:
|
|||||||
class BinaryOperator : public Instruction {
|
class BinaryOperator : public Instruction {
|
||||||
Use Source1, Source2;
|
Use Source1, Source2;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// getBinaryOperator() - Construct a binary instruction, given the opcode
|
||||||
|
// and the two operands.
|
||||||
|
//
|
||||||
|
static BinaryOperator *getBinaryOperator(unsigned Op, Value *S1, Value *S2);
|
||||||
|
|
||||||
BinaryOperator(unsigned iType, Value *S1, Value *S2,
|
BinaryOperator(unsigned iType, Value *S1, Value *S2,
|
||||||
const string &Name = "")
|
const string &Name = "")
|
||||||
: Instruction(S1->getType(), iType, Name), Source1(S1, this),
|
: Instruction(S1->getType(), iType, Name), Source1(S1, this),
|
||||||
@ -101,7 +113,7 @@ public:
|
|||||||
inline ~BinaryOperator() { dropAllReferences(); }
|
inline ~BinaryOperator() { dropAllReferences(); }
|
||||||
|
|
||||||
virtual Instruction *clone() const {
|
virtual Instruction *clone() const {
|
||||||
return Instruction::getBinaryOperator(getInstType(), Source1, Source2);
|
return getBinaryOperator(getInstType(), Source1, Source2);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void dropAllReferences() {
|
virtual void dropAllReferences() {
|
||||||
|
@ -85,9 +85,6 @@ public:
|
|||||||
return iType >= FirstBinaryOp && iType < NumBinaryOps;
|
return iType >= FirstBinaryOp && iType < NumBinaryOps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Instruction *getBinaryOperator(unsigned Op, Value *S1, Value *S2);
|
|
||||||
static Instruction *getUnaryOperator (unsigned Op, Value *Source);
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Exported enumerations...
|
// Exported enumerations...
|
||||||
@ -156,7 +153,7 @@ public:
|
|||||||
unsigned idx;
|
unsigned idx;
|
||||||
public:
|
public:
|
||||||
typedef OperandIterator<_Inst, _Val> _Self;
|
typedef OperandIterator<_Inst, _Val> _Self;
|
||||||
typedef forward_iterator_tag iterator_category;
|
typedef bidirectional_iterator_tag iterator_category;
|
||||||
typedef _Val pointer;
|
typedef _Val pointer;
|
||||||
|
|
||||||
inline OperandIterator(_Inst T) : Inst(T), idx(0) {} // begin iterator
|
inline OperandIterator(_Inst T) : Inst(T), idx(0) {} // begin iterator
|
||||||
|
@ -1851,7 +1851,7 @@ case 112:
|
|||||||
case 113:
|
case 113:
|
||||||
#line 854 "llvmAsmParser.y"
|
#line 854 "llvmAsmParser.y"
|
||||||
{
|
{
|
||||||
yyval.InstVal = Instruction::getBinaryOperator(yyvsp[-4].BinaryOpVal, getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
|
yyval.InstVal = BinaryOperator::getBinaryOperator(yyvsp[-4].BinaryOpVal, getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
|
||||||
if (yyval.InstVal == 0)
|
if (yyval.InstVal == 0)
|
||||||
ThrowException("binary operator returned null!");
|
ThrowException("binary operator returned null!");
|
||||||
;
|
;
|
||||||
@ -1859,7 +1859,7 @@ case 113:
|
|||||||
case 114:
|
case 114:
|
||||||
#line 859 "llvmAsmParser.y"
|
#line 859 "llvmAsmParser.y"
|
||||||
{
|
{
|
||||||
yyval.InstVal = Instruction::getUnaryOperator(yyvsp[-2].UnaryOpVal, getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
|
yyval.InstVal = UnaryOperator::getUnaryOperator(yyvsp[-2].UnaryOpVal, getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
|
||||||
if (yyval.InstVal == 0)
|
if (yyval.InstVal == 0)
|
||||||
ThrowException("unary operator returned null!");
|
ThrowException("unary operator returned null!");
|
||||||
;
|
;
|
||||||
|
@ -852,12 +852,12 @@ ValueRefList : Types ValueRef { // Used for PHI nodes and call statements...
|
|||||||
ValueRefListE : ValueRefList | /*empty*/ { $$ = 0; }
|
ValueRefListE : ValueRefList | /*empty*/ { $$ = 0; }
|
||||||
|
|
||||||
InstVal : BinaryOps Types ValueRef ',' ValueRef {
|
InstVal : BinaryOps Types ValueRef ',' ValueRef {
|
||||||
$$ = Instruction::getBinaryOperator($1, getVal($2, $3), getVal($2, $5));
|
$$ = BinaryOperator::getBinaryOperator($1, getVal($2, $3), getVal($2, $5));
|
||||||
if ($$ == 0)
|
if ($$ == 0)
|
||||||
ThrowException("binary operator returned null!");
|
ThrowException("binary operator returned null!");
|
||||||
}
|
}
|
||||||
| UnaryOps Types ValueRef {
|
| UnaryOps Types ValueRef {
|
||||||
$$ = Instruction::getUnaryOperator($1, getVal($2, $3));
|
$$ = UnaryOperator::getUnaryOperator($1, getVal($2, $3));
|
||||||
if ($$ == 0)
|
if ($$ == 0)
|
||||||
ThrowException("unary operator returned null!");
|
ThrowException("unary operator returned null!");
|
||||||
}
|
}
|
||||||
|
@ -93,12 +93,13 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
|
|
||||||
if (Raw.Opcode >= Instruction::FirstUnaryOp &&
|
if (Raw.Opcode >= Instruction::FirstUnaryOp &&
|
||||||
Raw.Opcode < Instruction::NumUnaryOps && Raw.NumOperands == 1) {
|
Raw.Opcode < Instruction::NumUnaryOps && Raw.NumOperands == 1) {
|
||||||
Res = Instruction::getUnaryOperator(Raw.Opcode, getValue(Raw.Ty, Raw.Arg1));
|
Res = UnaryOperator::getUnaryOperator(Raw.Opcode,getValue(Raw.Ty,Raw.Arg1));
|
||||||
return false;
|
return false;
|
||||||
} else if (Raw.Opcode >= Instruction::FirstBinaryOp &&
|
} else if (Raw.Opcode >= Instruction::FirstBinaryOp &&
|
||||||
Raw.Opcode < Instruction::NumBinaryOps && Raw.NumOperands == 2) {
|
Raw.Opcode < Instruction::NumBinaryOps && Raw.NumOperands == 2) {
|
||||||
Res = Instruction::getBinaryOperator(Raw.Opcode, getValue(Raw.Ty, Raw.Arg1),
|
Res = BinaryOperator::getBinaryOperator(Raw.Opcode,
|
||||||
getValue(Raw.Ty, Raw.Arg2));
|
getValue(Raw.Ty, Raw.Arg1),
|
||||||
|
getValue(Raw.Ty, Raw.Arg2));
|
||||||
return false;
|
return false;
|
||||||
} else if (Raw.Opcode == Instruction::PHINode) {
|
} else if (Raw.Opcode == Instruction::PHINode) {
|
||||||
PHINode *PN = new PHINode(Raw.Ty);
|
PHINode *PN = new PHINode(Raw.Ty);
|
||||||
|
@ -30,7 +30,8 @@ void Instruction::setName(const string &name) {
|
|||||||
if (PP && hasName()) PP->getSymbolTableSure()->insert(this);
|
if (PP && hasName()) PP->getSymbolTableSure()->insert(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction *Instruction::getBinaryOperator(unsigned Op, Value *S1, Value *S2) {
|
BinaryOperator *BinaryOperator::getBinaryOperator(unsigned Op,
|
||||||
|
Value *S1, Value *S2) {
|
||||||
switch (Op) {
|
switch (Op) {
|
||||||
case Add:
|
case Add:
|
||||||
return new AddInst(S1, S2);
|
return new AddInst(S1, S2);
|
||||||
@ -52,7 +53,7 @@ Instruction *Instruction::getBinaryOperator(unsigned Op, Value *S1, Value *S2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Instruction *Instruction::getUnaryOperator(unsigned Op, Value *Source) {
|
UnaryOperator *UnaryOperator::getUnaryOperator(unsigned Op, Value *Source) {
|
||||||
switch (Op) {
|
switch (Op) {
|
||||||
default:
|
default:
|
||||||
cerr << "Don't know how to GetUnaryOperator " << Op << endl;
|
cerr << "Don't know how to GetUnaryOperator " << Op << endl;
|
||||||
|
Reference in New Issue
Block a user