github.com/llir/llvm@v0.3.6/ir/block_conversion.go (about) 1 package ir 2 3 import ( 4 "github.com/llir/llvm/ir/types" 5 "github.com/llir/llvm/ir/value" 6 ) 7 8 // --- [ Conversion instructions ] --------------------------------------------- 9 10 // ~~~ [ trunc ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 11 12 // NewTrunc appends a new trunc instruction to the basic block based on the 13 // given source value and target type. 14 func (block *Block) NewTrunc(from value.Value, to types.Type) *InstTrunc { 15 inst := NewTrunc(from, to) 16 block.Insts = append(block.Insts, inst) 17 return inst 18 } 19 20 // ~~~ [ zext ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 21 22 // NewZExt appends a new zext instruction to the basic block based on the given 23 // source value and target type. 24 func (block *Block) NewZExt(from value.Value, to types.Type) *InstZExt { 25 inst := NewZExt(from, to) 26 block.Insts = append(block.Insts, inst) 27 return inst 28 } 29 30 // ~~~ [ sext ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 31 32 // NewSExt appends a new sext instruction to the basic block based on the given 33 // source value and target type. 34 func (block *Block) NewSExt(from value.Value, to types.Type) *InstSExt { 35 inst := NewSExt(from, to) 36 block.Insts = append(block.Insts, inst) 37 return inst 38 } 39 40 // ~~~ [ fptrunc ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 41 42 // NewFPTrunc appends a new fptrunc instruction to the basic block based on the 43 // given source value and target type. 44 func (block *Block) NewFPTrunc(from value.Value, to types.Type) *InstFPTrunc { 45 inst := NewFPTrunc(from, to) 46 block.Insts = append(block.Insts, inst) 47 return inst 48 } 49 50 // ~~~ [ fpext ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 51 52 // NewFPExt appends a new fpext instruction to the basic block based on the 53 // given source value and target type. 54 func (block *Block) NewFPExt(from value.Value, to types.Type) *InstFPExt { 55 inst := NewFPExt(from, to) 56 block.Insts = append(block.Insts, inst) 57 return inst 58 } 59 60 // ~~~ [ fptoui ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 61 62 // NewFPToUI appends a new fptoui instruction to the basic block based on the 63 // given source value and target type. 64 func (block *Block) NewFPToUI(from value.Value, to types.Type) *InstFPToUI { 65 inst := NewFPToUI(from, to) 66 block.Insts = append(block.Insts, inst) 67 return inst 68 } 69 70 // ~~~ [ fptosi ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 71 72 // NewFPToSI appends a new fptosi instruction to the basic block based on the 73 // given source value and target type. 74 func (block *Block) NewFPToSI(from value.Value, to types.Type) *InstFPToSI { 75 inst := NewFPToSI(from, to) 76 block.Insts = append(block.Insts, inst) 77 return inst 78 } 79 80 // ~~~ [ uitofp ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 81 82 // NewUIToFP appends a new uitofp instruction to the basic block based on the 83 // given source value and target type. 84 func (block *Block) NewUIToFP(from value.Value, to types.Type) *InstUIToFP { 85 inst := NewUIToFP(from, to) 86 block.Insts = append(block.Insts, inst) 87 return inst 88 } 89 90 // ~~~ [ sitofp ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 91 92 // NewSIToFP appends a new sitofp instruction to the basic block based on the 93 // given source value and target type. 94 func (block *Block) NewSIToFP(from value.Value, to types.Type) *InstSIToFP { 95 inst := NewSIToFP(from, to) 96 block.Insts = append(block.Insts, inst) 97 return inst 98 } 99 100 // ~~~ [ ptrtoint ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 101 102 // NewPtrToInt appends a new ptrtoint instruction to the basic block based on 103 // the given source value and target type. 104 func (block *Block) NewPtrToInt(from value.Value, to types.Type) *InstPtrToInt { 105 inst := NewPtrToInt(from, to) 106 block.Insts = append(block.Insts, inst) 107 return inst 108 } 109 110 // ~~~ [ inttoptr ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 111 112 // NewIntToPtr appends a new inttoptr instruction to the basic block based on 113 // the given source value and target type. 114 func (block *Block) NewIntToPtr(from value.Value, to types.Type) *InstIntToPtr { 115 inst := NewIntToPtr(from, to) 116 block.Insts = append(block.Insts, inst) 117 return inst 118 } 119 120 // ~~~ [ bitcast ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 121 122 // NewBitCast appends a new bitcast instruction to the basic block based on the 123 // given source value and target type. 124 func (block *Block) NewBitCast(from value.Value, to types.Type) *InstBitCast { 125 inst := NewBitCast(from, to) 126 block.Insts = append(block.Insts, inst) 127 return inst 128 } 129 130 // ~~~ [ addrspacecast ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 131 132 // NewAddrSpaceCast appends a new addrspacecast instruction to the basic block 133 // based on the given source value and target type. 134 func (block *Block) NewAddrSpaceCast(from value.Value, to types.Type) *InstAddrSpaceCast { 135 inst := NewAddrSpaceCast(from, to) 136 block.Insts = append(block.Insts, inst) 137 return inst 138 }