Skip to content

Commit

Permalink
Issue #59: adding subroutine opcodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
lialan committed Apr 28, 2020
1 parent c28d0f1 commit 2794daf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
13 changes: 10 additions & 3 deletions lib/Target/EVM/EVM.td
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ def HasEIP211 : Predicate<"Subtarget->hasEIP211()">,

def HasEIP615 : Predicate<"Subtarget->hasEIP615()">,
AssemblerPredicate<"FeatureEIP615">;
*/

def FeatureSubroutine : SubtargetFeature<"subroutine",
"HasSubroutine",
"true",
"EVM Subroutine support">;

def HasSubroutine : Predicate<"Subtarget->hasSubroutine()">,
AssemblerPredicate<"FeatureSubroutine">;

class Proc<string Name, list<SubtargetFeature> Features>
: Processor<Name, NoItineraries, Features>;

def : Proc<"generic", []>;
def : Proc<"eip211", [EIP211]>;
def : Proc<"eip615", [EIP211, EIP615]>;
*/
def : Proc<"EVM15", [FeatureSubroutine]>;

//===----------------------------------------------------------------------===//
// Registers, instruction descriptions.
Expand Down
15 changes: 9 additions & 6 deletions lib/Target/EVM/EVMInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,17 @@ def DUP16: EVMInst<(outs), (ins), [], "true", "DUP16", 0x8f, 3>;

let isBranch = 1, isBarrier = 1, isTerminator = 1 in {
defm JUMPTO : Inst_1_0<"JUMPTO", [], 0xb0, 8>;
/*
defm JUMPIF : // TODO: argument type is 4 bytes.
: RSInst<(outs GPR:$dst), (ins GPR:$src1, GPR:$src2),
pattern,
"JUMPIF\t$dst, $src1, $src2", "JUMPIF", 0xb1, 10>;
*/

def JUMPSUB :
EVMInst<(outs), (ins I256Imm:$tgt), [], "true", "JUMPSUB \t$tgt", 0xb3, 8>;
}

def BEGINSUB :
EVMInst<(outs), (ins), [], "true", "BEGINSUB", 0xb5, 1>;
def RETURNSUB :
EVMInst<(outs), (ins), [], "true", "RETURNSUB", 0xb7, 2>;


let mayStore = 1, hasSideEffects = 1 in {
defm CREATE : Inst_3_1<"CREATE",
[(set GPR:$dst,
Expand Down
8 changes: 2 additions & 6 deletions lib/Target/EVM/EVMSubtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ class StringRef;
class EVMSubtarget : public EVMGenSubtargetInfo {
virtual void anchor();

// EVM Change
bool HasEIP211 = false;
bool HasEIP615 = false;
bool HasSubroutine = true;

bool hasEIP211() const { return HasEIP211; }
bool hasEIP615() const { return HasEIP615; }
// end of EVM Change
bool hasSubroutine() const {return HasSubroutine; }

EVMFrameLowering FrameLowering;
EVMInstrInfo InstrInfo;
Expand Down

0 comments on commit 2794daf

Please sign in to comment.