File: gnu.go

package info (click to toggle)
golang-golang-x-arch 0.0~git20201207.1e68675-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,724 kB
  • sloc: ansic: 1,832; makefile: 42
file content (35 lines) | stat: -rw-r--r-- 1,036 bytes parent folder | download | duplicates (34)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package arm64asm

import (
	"strings"
)

// GNUSyntax returns the GNU assembler syntax for the instruction, as defined by GNU binutils.
// This form typically matches the syntax defined in the ARM Reference Manual.
func GNUSyntax(inst Inst) string {
	switch inst.Op {
	case RET:
		if r, ok := inst.Args[0].(Reg); ok && r == X30 {
			return "ret"
		}
	case B:
		if _, ok := inst.Args[0].(Cond); ok {
			return strings.ToLower("b." + inst.Args[0].String() + " " + inst.Args[1].String())
		}
	case SYSL:
		result := strings.ToLower(inst.String())
		return strings.Replace(result, "c", "C", -1)
	case DCPS1, DCPS2, DCPS3, CLREX:
		return strings.ToLower(strings.TrimSpace(inst.String()))
	case ISB:
		if strings.Contains(inst.String(), "SY") {
			result := strings.TrimSuffix(inst.String(), " SY")
			return strings.ToLower(result)
		}
	}
	return strings.ToLower(inst.String())
}