github.com/llir/llvm@v0.3.6/ir/block_binary.go (about)

     1  package ir
     2  
     3  import (
     4  	"github.com/llir/llvm/ir/value"
     5  )
     6  
     7  // --- [ Binary instructions ] -------------------------------------------------
     8  
     9  // ~~~ [ add ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    10  
    11  // NewAdd appends a new add instruction to the basic block based on the given
    12  // operands.
    13  func (block *Block) NewAdd(x, y value.Value) *InstAdd {
    14  	inst := NewAdd(x, y)
    15  	block.Insts = append(block.Insts, inst)
    16  	return inst
    17  }
    18  
    19  // ~~~ [ fadd ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    20  
    21  // NewFAdd appends a new fadd instruction to the basic block based on the given
    22  // operands.
    23  func (block *Block) NewFAdd(x, y value.Value) *InstFAdd {
    24  	inst := NewFAdd(x, y)
    25  	block.Insts = append(block.Insts, inst)
    26  	return inst
    27  }
    28  
    29  // ~~~ [ sub ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    30  
    31  // NewSub appends a new sub instruction to the basic block based on the given
    32  // operands.
    33  func (block *Block) NewSub(x, y value.Value) *InstSub {
    34  	inst := NewSub(x, y)
    35  	block.Insts = append(block.Insts, inst)
    36  	return inst
    37  }
    38  
    39  // ~~~ [ fsub ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    40  
    41  // NewFSub appends a new fsub instruction to the basic block based on the given
    42  // operands.
    43  func (block *Block) NewFSub(x, y value.Value) *InstFSub {
    44  	inst := NewFSub(x, y)
    45  	block.Insts = append(block.Insts, inst)
    46  	return inst
    47  }
    48  
    49  // ~~~ [ mul ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    50  
    51  // NewMul appends a new mul instruction to the basic block based on the given
    52  // operands.
    53  func (block *Block) NewMul(x, y value.Value) *InstMul {
    54  	inst := NewMul(x, y)
    55  	block.Insts = append(block.Insts, inst)
    56  	return inst
    57  }
    58  
    59  // ~~~ [ fmul ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    60  
    61  // NewFMul appends a new fmul instruction to the basic block based on the given
    62  // operands.
    63  func (block *Block) NewFMul(x, y value.Value) *InstFMul {
    64  	inst := NewFMul(x, y)
    65  	block.Insts = append(block.Insts, inst)
    66  	return inst
    67  }
    68  
    69  // ~~~ [ udiv ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    70  
    71  // NewUDiv appends a new udiv instruction to the basic block based on the given
    72  // operands.
    73  func (block *Block) NewUDiv(x, y value.Value) *InstUDiv {
    74  	inst := NewUDiv(x, y)
    75  	block.Insts = append(block.Insts, inst)
    76  	return inst
    77  }
    78  
    79  // ~~~ [ sdiv ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    80  
    81  // NewSDiv appends a new sdiv instruction to the basic block based on the given
    82  // operands.
    83  func (block *Block) NewSDiv(x, y value.Value) *InstSDiv {
    84  	inst := NewSDiv(x, y)
    85  	block.Insts = append(block.Insts, inst)
    86  	return inst
    87  }
    88  
    89  // ~~~ [ fdiv ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    90  
    91  // NewFDiv appends a new fdiv instruction to the basic block based on the given
    92  // operands.
    93  func (block *Block) NewFDiv(x, y value.Value) *InstFDiv {
    94  	inst := NewFDiv(x, y)
    95  	block.Insts = append(block.Insts, inst)
    96  	return inst
    97  }
    98  
    99  // ~~~ [ urem ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   100  
   101  // NewURem appends a new urem instruction to the basic block based on the given
   102  // operands.
   103  func (block *Block) NewURem(x, y value.Value) *InstURem {
   104  	inst := NewURem(x, y)
   105  	block.Insts = append(block.Insts, inst)
   106  	return inst
   107  }
   108  
   109  // ~~~ [ srem ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   110  
   111  // NewSRem appends a new srem instruction to the basic block based on the given
   112  // operands.
   113  func (block *Block) NewSRem(x, y value.Value) *InstSRem {
   114  	inst := NewSRem(x, y)
   115  	block.Insts = append(block.Insts, inst)
   116  	return inst
   117  }
   118  
   119  // ~~~ [ frem ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   120  
   121  // NewFRem appends a new frem instruction to the basic block based on the given
   122  // operands.
   123  func (block *Block) NewFRem(x, y value.Value) *InstFRem {
   124  	inst := NewFRem(x, y)
   125  	block.Insts = append(block.Insts, inst)
   126  	return inst
   127  }