github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/internal/obj/riscv/obj.go (about) 1 // Copyright © 2015 The Go Authors. All rights reserved. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 package riscv 22 23 import ( 24 "github.com/shogo82148/std/cmd/internal/obj" 25 "github.com/shogo82148/std/cmd/internal/sys" 26 ) 27 28 // InvertBranch inverts the condition of a conditional branch. 29 func InvertBranch(as obj.As) obj.As 30 31 // Split32BitImmediate splits a signed 32-bit immediate into a signed 20-bit 32 // upper immediate and a signed 12-bit lower immediate to be added to the upper 33 // result. For example, high may be used in LUI and low in a following ADDI to 34 // generate a full 32-bit constant. 35 func Split32BitImmediate(imm int64) (low, high int64, err error) 36 37 func EncodeBImmediate(imm int64) (int64, error) 38 39 func EncodeCBImmediate(imm int64) (int64, error) 40 41 func EncodeCJImmediate(imm int64) (int64, error) 42 43 func EncodeIImmediate(imm int64) (int64, error) 44 45 func EncodeJImmediate(imm int64) (int64, error) 46 47 func EncodeSImmediate(imm int64) (int64, error) 48 49 func EncodeUImmediate(imm int64) (int64, error) 50 51 func ParseSuffix(prog *obj.Prog, cond string) (err error) 52 53 var LinkRISCV64 = obj.LinkArch{ 54 Arch: sys.ArchRISCV64, 55 Init: buildop, 56 Preprocess: preprocess, 57 Assemble: assemble, 58 Progedit: progedit, 59 UnaryDst: unaryDst, 60 DWARFRegisters: RISCV64DWARFRegisters, 61 }