github.com/bir3/gocompiler@v0.9.2202/src/xvendor/golang.org/x/arch/arm64/arm64asm/gnu.go (about) 1 // Copyright 2017 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package arm64asm 6 7 import ( 8 "strings" 9 ) 10 11 // GNUSyntax returns the GNU assembler syntax for the instruction, as defined by GNU binutils. 12 // This form typically matches the syntax defined in the ARM Reference Manual. 13 func GNUSyntax(inst Inst) string { 14 switch inst.Op { 15 case RET: 16 if r, ok := inst.Args[0].(Reg); ok && r == X30 { 17 return "ret" 18 } 19 case B: 20 if _, ok := inst.Args[0].(Cond); ok { 21 return strings.ToLower("b." + inst.Args[0].String() + " " + inst.Args[1].String()) 22 } 23 case SYSL: 24 result := strings.ToLower(inst.String()) 25 return strings.Replace(result, "c", "C", -1) 26 case DCPS1, DCPS2, DCPS3, CLREX: 27 return strings.ToLower(strings.TrimSpace(inst.String())) 28 case ISB: 29 if strings.Contains(inst.String(), "SY") { 30 result := strings.TrimSuffix(inst.String(), " SY") 31 return strings.ToLower(result) 32 } 33 } 34 return strings.ToLower(inst.String()) 35 }