Skip to content

Commit

Permalink
operands init
Browse files Browse the repository at this point in the history
  • Loading branch information
dannypsnl committed Aug 21, 2021
1 parent 9e62c17 commit 9363750
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ir/inst_aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type InstExtractValue struct {
Metadata
}

func (inst *InstExtractValue) Operands() []value.Value { return []value.Value{inst.X} }

// NewExtractValue returns a new extractvalue instruction based on the given
// aggregate value and indicies.
func NewExtractValue(x value.Value, indices ...uint64) *InstExtractValue {
Expand Down Expand Up @@ -90,6 +92,8 @@ type InstInsertValue struct {
Metadata
}

func (inst *InstInsertValue) Operands() []value.Value { return []value.Value{inst.X, inst.Elem} }

// NewInsertValue returns a new insertvalue instruction based on the given
// aggregate value, element and indicies.
func NewInsertValue(x, elem value.Value, indices ...uint64) *InstInsertValue {
Expand Down
24 changes: 24 additions & 0 deletions ir/inst_binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type InstAdd struct {
Metadata
}

func (inst *InstAdd) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewAdd returns a new add instruction based on the given operands.
func NewAdd(x, y value.Value) *InstAdd {
inst := &InstAdd{X: x, Y: y}
Expand Down Expand Up @@ -89,6 +91,8 @@ type InstFAdd struct {
Metadata
}

func (inst *InstFAdd) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewFAdd returns a new fadd instruction based on the given operands.
func NewFAdd(x, y value.Value) *InstFAdd {
inst := &InstFAdd{X: x, Y: y}
Expand Down Expand Up @@ -148,6 +152,8 @@ type InstSub struct {
Metadata
}

func (inst *InstSub) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewSub returns a new sub instruction based on the given operands.
func NewSub(x, y value.Value) *InstSub {
inst := &InstSub{X: x, Y: y}
Expand Down Expand Up @@ -207,6 +213,8 @@ type InstFSub struct {
Metadata
}

func (inst *InstFSub) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewFSub returns a new fsub instruction based on the given operands.
func NewFSub(x, y value.Value) *InstFSub {
inst := &InstFSub{X: x, Y: y}
Expand Down Expand Up @@ -266,6 +274,8 @@ type InstMul struct {
Metadata
}

func (inst *InstMul) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewMul returns a new mul instruction based on the given operands.
func NewMul(x, y value.Value) *InstMul {
inst := &InstMul{X: x, Y: y}
Expand Down Expand Up @@ -325,6 +335,8 @@ type InstFMul struct {
Metadata
}

func (inst *InstFMul) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewFMul returns a new fmul instruction based on the given operands.
func NewFMul(x, y value.Value) *InstFMul {
inst := &InstFMul{X: x, Y: y}
Expand Down Expand Up @@ -384,6 +396,8 @@ type InstUDiv struct {
Metadata
}

func (inst *InstUDiv) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewUDiv returns a new udiv instruction based on the given operands.
func NewUDiv(x, y value.Value) *InstUDiv {
inst := &InstUDiv{X: x, Y: y}
Expand Down Expand Up @@ -443,6 +457,8 @@ type InstSDiv struct {
Metadata
}

func (inst *InstSDiv) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewSDiv returns a new sdiv instruction based on the given operands.
func NewSDiv(x, y value.Value) *InstSDiv {
inst := &InstSDiv{X: x, Y: y}
Expand Down Expand Up @@ -502,6 +518,8 @@ type InstFDiv struct {
Metadata
}

func (inst *InstFDiv) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewFDiv returns a new fdiv instruction based on the given operands.
func NewFDiv(x, y value.Value) *InstFDiv {
inst := &InstFDiv{X: x, Y: y}
Expand Down Expand Up @@ -559,6 +577,8 @@ type InstURem struct {
Metadata
}

func (inst *InstURem) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewURem returns a new urem instruction based on the given operands.
func NewURem(x, y value.Value) *InstURem {
inst := &InstURem{X: x, Y: y}
Expand Down Expand Up @@ -612,6 +632,8 @@ type InstSRem struct {
Metadata
}

func (inst *InstSRem) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewSRem returns a new srem instruction based on the given operands.
func NewSRem(x, y value.Value) *InstSRem {
inst := &InstSRem{X: x, Y: y}
Expand Down Expand Up @@ -667,6 +689,8 @@ type InstFRem struct {
Metadata
}

func (inst *InstFRem) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewFRem returns a new frem instruction based on the given operands.
func NewFRem(x, y value.Value) *InstFRem {
inst := &InstFRem{X: x, Y: y}
Expand Down
18 changes: 18 additions & 0 deletions ir/inst_bitwise.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type InstShl struct {
Metadata
}

func (inst *InstShl) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewShl returns a new shl instruction based on the given operands.
func NewShl(x, y value.Value) *InstShl {
inst := &InstShl{X: x, Y: y}
Expand Down Expand Up @@ -89,6 +91,8 @@ type InstLShr struct {
Metadata
}

func (inst *InstLShr) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewLShr returns a new lshr instruction based on the given operands.
func NewLShr(x, y value.Value) *InstLShr {
inst := &InstLShr{X: x, Y: y}
Expand Down Expand Up @@ -148,6 +152,8 @@ type InstAShr struct {
Metadata
}

func (inst *InstAShr) Operands() []value.Value { return []value.Value{inst.X, inst.Y} }

// NewAShr returns a new ashr instruction based on the given operands.
func NewAShr(x, y value.Value) *InstAShr {
inst := &InstAShr{X: x, Y: y}
Expand Down Expand Up @@ -205,6 +211,10 @@ type InstAnd struct {
Metadata
}

func (inst *InstAnd) Operands() []value.Value {
return []value.Value{inst.X, inst.Y}
}

// NewAnd returns a new and instruction based on the given operands.
func NewAnd(x, y value.Value) *InstAnd {
inst := &InstAnd{X: x, Y: y}
Expand Down Expand Up @@ -258,6 +268,10 @@ type InstOr struct {
Metadata
}

func (inst *InstOr) Operands() []value.Value {
return []value.Value{inst.X, inst.Y}
}

// NewOr returns a new or instruction based on the given operands.
func NewOr(x, y value.Value) *InstOr {
inst := &InstOr{X: x, Y: y}
Expand Down Expand Up @@ -311,6 +325,10 @@ type InstXor struct {
Metadata
}

func (inst *InstXor) Operands() []value.Value {
return []value.Value{inst.X, inst.Y}
}

// NewXor returns a new xor instruction based on the given operands.
func NewXor(x, y value.Value) *InstXor {
inst := &InstXor{X: x, Y: y}
Expand Down
52 changes: 52 additions & 0 deletions ir/inst_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ type InstTrunc struct {
Metadata
}

func (inst *InstTrunc) Operands() []value.Value {
return []value.Value{inst.From}
}

// NewTrunc returns a new trunc instruction based on the given source value and
// target type.
func NewTrunc(from value.Value, to types.Type) *InstTrunc {
Expand Down Expand Up @@ -101,6 +105,10 @@ type InstZExt struct {
Metadata
}

func (inst *InstZExt) Operands() []value.Value {
return []value.Value{inst.From}
}

// NewZExt returns a new zext instruction based on the given source value and
// target type.
func NewZExt(from value.Value, to types.Type) *InstZExt {
Expand Down Expand Up @@ -148,6 +156,10 @@ type InstSExt struct {
Metadata
}

func (inst *InstSExt) Operands() []value.Value {
return []value.Value{inst.From}
}

// NewSExt returns a new sext instruction based on the given source value and
// target type.
func NewSExt(from value.Value, to types.Type) *InstSExt {
Expand Down Expand Up @@ -195,6 +207,10 @@ type InstFPTrunc struct {
Metadata
}

func (inst *InstFPTrunc) Operands() []value.Value {
return []value.Value{inst.From}
}

// NewFPTrunc returns a new fptrunc instruction based on the given source value
// and target type.
func NewFPTrunc(from value.Value, to types.Type) *InstFPTrunc {
Expand Down Expand Up @@ -242,6 +258,10 @@ type InstFPExt struct {
Metadata
}

func (inst *InstFPExt) Operands() []value.Value {
return []value.Value{inst.From}
}

// NewFPExt returns a new fpext instruction based on the given source value and
// target type.
func NewFPExt(from value.Value, to types.Type) *InstFPExt {
Expand Down Expand Up @@ -289,6 +309,10 @@ type InstFPToUI struct {
Metadata
}

func (inst *InstFPToUI) Operands() []value.Value {
return []value.Value{inst.From}
}

// NewFPToUI returns a new fptoui instruction based on the given source value
// and target type.
func NewFPToUI(from value.Value, to types.Type) *InstFPToUI {
Expand Down Expand Up @@ -336,6 +360,10 @@ type InstFPToSI struct {
Metadata
}

func (inst *InstFPToSI) Operands() []value.Value {
return []value.Value{inst.From}
}

// NewFPToSI returns a new fptosi instruction based on the given source value
// and target type.
func NewFPToSI(from value.Value, to types.Type) *InstFPToSI {
Expand Down Expand Up @@ -383,6 +411,10 @@ type InstUIToFP struct {
Metadata
}

func (inst *InstUIToFP) Operands() []value.Value {
return []value.Value{inst.From}
}

// NewUIToFP returns a new uitofp instruction based on the given source value
// and target type.
func NewUIToFP(from value.Value, to types.Type) *InstUIToFP {
Expand Down Expand Up @@ -430,6 +462,10 @@ type InstSIToFP struct {
Metadata
}

func (inst *InstSIToFP) Operands() []value.Value {
return []value.Value{inst.From}
}

// NewSIToFP returns a new sitofp instruction based on the given source value
// and target type.
func NewSIToFP(from value.Value, to types.Type) *InstSIToFP {
Expand Down Expand Up @@ -477,6 +513,10 @@ type InstPtrToInt struct {
Metadata
}

func (inst *InstPtrToInt) Operands() []value.Value {
return []value.Value{inst.From}
}

// NewPtrToInt returns a new ptrtoint instruction based on the given source
// value and target type.
func NewPtrToInt(from value.Value, to types.Type) *InstPtrToInt {
Expand Down Expand Up @@ -524,6 +564,10 @@ type InstIntToPtr struct {
Metadata
}

func (inst *InstIntToPtr) Operands() []value.Value {
return []value.Value{inst.From}
}

// NewIntToPtr returns a new inttoptr instruction based on the given source
// value and target type.
func NewIntToPtr(from value.Value, to types.Type) *InstIntToPtr {
Expand Down Expand Up @@ -571,6 +615,10 @@ type InstBitCast struct {
Metadata
}

func (inst *InstBitCast) Operands() []value.Value {
return []value.Value{inst.From}
}

// NewBitCast returns a new bitcast instruction based on the given source value
// and target type.
func NewBitCast(from value.Value, to types.Type) *InstBitCast {
Expand Down Expand Up @@ -618,6 +666,10 @@ type InstAddrSpaceCast struct {
Metadata
}

func (inst *InstAddrSpaceCast) Operands() []value.Value {
return []value.Value{inst.From}
}

// NewAddrSpaceCast returns a new addrspacecast instruction based on the given
// source value and target type.
func NewAddrSpaceCast(from value.Value, to types.Type) *InstAddrSpaceCast {
Expand Down
Loading

0 comments on commit 9363750

Please sign in to comment.