1 // Derived from Inferno utils/6l/l.h and related files.
2 // https://bitbucket.org/inferno-os/inferno-os/src/master/utils/6l/l.h
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
6 // Portions Copyright © 1997-1999 Vita Nuova Limited
7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
8 // Portions Copyright © 2004,2006 Bruce Ellis
9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
11 // Portions Copyright © 2009 The Go Authors. All rights reserved.
13 // Permission is hereby granted, free of charge, to any person obtaining a copy
14 // of this software and associated documentation files (the "Software"), to deal
15 // in the Software without restriction, including without limitation the rights
16 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 // copies of the Software, and to permit persons to whom the Software is
18 // furnished to do so, subject to the following conditions:
20 // The above copyright notice and this permission notice shall be included in
21 // all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
44 // An Addr is an argument to an instruction.
45 // The general forms and their encodings are:
47 // sym±offset(symkind)(reg)(index*scale)
48 // Memory reference at address &sym(symkind) + offset + reg + index*scale.
49 // Any of sym(symkind), ±offset, (reg), (index*scale), and *scale can be omitted.
50 // If (reg) and *scale are both omitted, the resulting expression (index) is parsed as (reg).
51 // To force a parsing as index*scale, write (index*1).
54 // name = symkind (NAME_AUTO, ...) or 0 (NAME_NONE)
58 // index = index (REG_*)
59 // scale = scale (1, 2, 4, 8)
62 // Effective address of memory reference <mem>, defined above.
63 // Encoding: same as memory reference, but type = TYPE_ADDR.
66 // This is a special case of $<mem>, in which only ±offset is present.
67 // It has a separate type for easy recognition.
70 // offset = ±integer value
73 // Indirect reference through memory reference <mem>, defined above.
74 // Only used on x86 for CALL/JMP *sym(SB), which calls/jumps to a function
75 // pointer stored in the data word sym(SB), not a function named sym(SB).
76 // Encoding: same as above, but type = TYPE_INDIR.
80 // On machines with actual SB registers, $*$<mem> forced the
81 // instruction encoding to use a full 32-bit constant, never a
82 // reference relative to SB.
84 // $<floating point literal>
85 // Floating point constant value.
88 // val = floating point value
90 // $<string literal, up to 8 chars>
91 // String literal value (raw bytes used for DATA instruction).
97 // Any register: integer, floating point, control, segment, and so on.
98 // If looking for specific register kind, must check type and reg value range.
105 // type = TYPE_BRANCH
106 // val = Prog* reference OR ELSE offset = target pc (branch takes priority)
109 // Final argument to TEXT, specifying local frame size x and argument size y.
110 // In this form, x and y are integer literals only, not arbitrary expressions.
111 // This avoids parsing ambiguities due to the use of - as a separator.
112 // The ± are optional.
113 // If the final argument to TEXT omits the -±y, the encoding should still
114 // use TYPE_TEXTSIZE (not TYPE_CONST), with u.argsize = ArgsSizeUnknown.
116 // type = TYPE_TEXTSIZE
120 // reg<<shift, reg>>shift, reg->shift, reg@>shift
121 // Shifted register value, for ARM and ARM64.
122 // In this form, reg must be a register and shift can be a register or an integer constant.
126 // offset = (reg&15) | shifttype<<5 | count
127 // shifttype = 0, 1, 2, 3 for <<, >>, ->, @>
128 // count = (reg&15)<<8 | 1<<4 for a register shift count, (n&31)<<7 for an integer constant.
130 // offset = (reg&31)<<16 | shifttype<<22 | (count&63)<<10
131 // shifttype = 0, 1, 2 for <<, >>, ->
134 // A destination register pair. When used as the last argument of an instruction,
135 // this form makes clear that both registers are destinations.
137 // type = TYPE_REGREG
138 // reg = first register
139 // offset = second register
141 // [reg, reg, reg-reg]
142 // Register list for ARM, ARM64, 386/AMD64.
144 // type = TYPE_REGLIST
146 // offset = bit mask of registers in list; R0 is low bit.
148 // offset = register count (Q:size) | arrangement (opcode) | first register
150 // reg = range low register
151 // offset = 2 packed registers + kind tag (see x86.EncodeRegisterRange)
154 // Register pair for ARM.
158 // Register pair for PPC64.
161 // reg = first register
162 // index = second register
166 // Register extension for ARM64
169 // reg = REG_[US]XT[BHWX] + register + shift amount
170 // offset = ((reg&31) << 16) | (exttype << 13) | (amount<<10)
173 // Register arrangement for ARM64 SIMD register
174 // e.g.: V1.S4, V2.S2, V7.D2, V2.H4, V6.B16
177 // reg = REG_ARNG + register + arrangement
180 // Register element for ARM64
183 // reg = REG_ELEM + register + arrangement
184 // index = element index
189 Scale int16 // Sometimes holds a register.
197 // for TYPE_SCONST, a string
198 // for TYPE_FCONST, a float64
199 // for TYPE_BRANCH, a *Prog (optional)
200 // for TYPE_TEXTSIZE, an int32 (optional)
207 NAME_NONE AddrName = iota
212 // A reference to name@GOT(SB) is a reference to the entry in the global offset
215 // Indicates that this is a reference to a TOC anchor.
219 //go:generate stringer -type AddrType
224 TYPE_NONE AddrType = iota
240 func (a *Addr) Target() *Prog {
241 if a.Type == TYPE_BRANCH && a.Val != nil {
246 func (a *Addr) SetTarget(t *Prog) {
247 if a.Type != TYPE_BRANCH {
248 panic("setting branch target when type is not TYPE_BRANCH")
253 func (a *Addr) SetConst(v int64) {
259 // Prog describes a single machine instruction.
261 // The general instruction form is:
263 // (1) As.Scond From [, ...RestArgs], To
264 // (2) As.Scond From, Reg [, ...RestArgs], To, RegTo2
266 // where As is an opcode and the others are arguments:
267 // From, Reg are sources, and To, RegTo2 are destinations.
268 // RestArgs can hold additional sources and destinations.
269 // Usually, not all arguments are present.
270 // For example, MOVL R1, R2 encodes using only As=MOVL, From=R1, To=R2.
271 // The Scond field holds additional condition bits for systems (like arm)
272 // that have generalized conditional execution.
273 // (2) form is present for compatibility with older code,
274 // to avoid too much changes in a single swing.
275 // (1) scheme is enough to express any kind of operand combination.
277 // Jump instructions use the To.Val field to point to the target *Prog,
278 // which must be in the same linked list as the jump instruction.
280 // The Progs for a given function are arranged in a list linked through the Link field.
282 // Each Prog is charged to a specific source line in the debug information,
283 // specified by Pos.Line().
284 // Every Prog has a Ctxt field that defines its context.
285 // For performance reasons, Progs usually are usually bulk allocated, cached, and reused;
286 // those bulk allocators should always be used, rather than new(Prog).
288 // The other fields not yet mentioned are for use by the back ends and should
289 // be left zeroed by creators of Prog lists.
291 Ctxt *Link // linker context
292 Link *Prog // next Prog in linked list
293 From Addr // first source operand
294 RestArgs []AddrPos // can pack any operands that not fit into {Prog.From, Prog.To}
295 To Addr // destination operand (second is RegTo2 below)
296 Pool *Prog // constant pool entry, for arm,arm64 back ends
297 Forwd *Prog // for x86 back end
298 Rel *Prog // for x86, arm back ends
299 Pc int64 // for back ends or assembler: virtual or actual program counter, depending on phase
300 Pos src.XPos // source position of this instruction
301 Spadj int32 // effect of instruction on stack pointer (increment or decrement amount)
302 As As // assembler opcode
303 Reg int16 // 2nd source operand
304 RegTo2 int16 // 2nd destination operand
305 Mark uint16 // bitmask of arch-specific items
306 Optab uint16 // arch-specific opcode index
307 Scond uint8 // bits that describe instruction suffixes (e.g. ARM conditions)
308 Back uint8 // for x86 back end: backwards branch state
309 Ft uint8 // for x86 back end: type index of Prog.From
310 Tt uint8 // for x86 back end: type index of Prog.To
311 Isize uint8 // for x86 back end: size of the instruction in bytes
314 // Pos indicates whether the oprand is the source or the destination.
315 type AddrPos struct {
323 Source OperandPos = iota
327 // From3Type returns p.GetFrom3().Type, or TYPE_NONE when
328 // p.GetFrom3() returns nil.
330 // Deprecated: for the same reasons as Prog.GetFrom3.
331 func (p *Prog) From3Type() AddrType {
332 if p.RestArgs == nil {
335 return p.RestArgs[0].Type
338 // GetFrom3 returns second source operand (the first is Prog.From).
339 // In combination with Prog.From and Prog.To it makes common 3 operand
340 // case easier to use.
342 // Should be used only when RestArgs is set with SetFrom3.
344 // Deprecated: better use RestArgs directly or define backend-specific getters.
345 // Introduced to simplify transition to []Addr.
346 // Usage of this is discouraged due to fragility and lack of guarantees.
347 func (p *Prog) GetFrom3() *Addr {
348 if p.RestArgs == nil {
351 return &p.RestArgs[0].Addr
354 // SetFrom3 assigns []Args{{a, 0}} to p.RestArgs.
355 // In pair with Prog.GetFrom3 it can help in emulation of Prog.From3.
357 // Deprecated: for the same reasons as Prog.GetFrom3.
358 func (p *Prog) SetFrom3(a Addr) {
359 p.RestArgs = []AddrPos{{a, Source}}
362 // SetTo2 assings []Args{{a, 1}} to p.RestArgs when the second destination
363 // operand does not fit into prog.RegTo2.
364 func (p *Prog) SetTo2(a Addr) {
365 p.RestArgs = []AddrPos{{a, Destination}}
368 // GetTo2 returns the second destination operand.
369 func (p *Prog) GetTo2() *Addr {
370 if p.RestArgs == nil {
373 return &p.RestArgs[0].Addr
376 // SetRestArgs assigns more than one source operands to p.RestArgs.
377 func (p *Prog) SetRestArgs(args []Addr) {
378 for i := range args {
379 p.RestArgs = append(p.RestArgs, AddrPos{args[i], Source})
383 // An As denotes an assembler opcode.
384 // There are some portable opcodes, declared here in package obj,
385 // that are common to all architectures.
386 // However, the majority of opcodes are arch-specific
387 // and are declared in their respective architecture's subpackage.
390 // These are the portable opcodes.
409 // Each architecture is allotted a distinct subspace of opcode values
410 // for declaring its arch-specific opcodes.
411 // Within this subspace, the first arch-specific opcode should be
412 // at offset A_ARCHSPECIFIC.
414 // Subspaces are aligned to a power of two so opcodes can be masked
415 // with AMask and used as compact array indices.
417 ABase386 = (1 + iota) << 11
427 AllowedOpCodes = 1 << 11 // The number of opcodes available for any given architecture.
428 AMask = AllowedOpCodes - 1 // AND with this to use the opcode as an array index.
431 // An LSym is the sort of symbol that is written to an object file.
432 // It represents Go symbols in a flat pkg+"."+name namespace.
443 Extra *interface{} // *FuncInfo or *FileInfo, if present
450 // A FuncInfo contains extra fields for STEXT symbols.
451 type FuncInfo struct {
457 Autot map[*LSym]struct{}
465 dwarfDebugLinesSym *LSym
470 OpenCodedDeferInfo *LSym
475 // NewFuncInfo allocates and returns a FuncInfo for LSym.
476 func (s *LSym) NewFuncInfo() *FuncInfo {
478 panic(fmt.Sprintf("invalid use of LSym - NewFuncInfo with Extra of type %T", *s.Extra))
481 s.Extra = new(interface{})
486 // Func returns the *FuncInfo associated with s, or else nil.
487 func (s *LSym) Func() *FuncInfo {
491 f, _ := (*s.Extra).(*FuncInfo)
495 // A FileInfo contains extra fields for SDATA symbols backed by files.
496 // (If LSym.Extra is a *FileInfo, LSym.P == nil.)
497 type FileInfo struct {
498 Name string // name of file to read into object file
499 Size int64 // length of file
502 // NewFileInfo allocates and returns a FileInfo for LSym.
503 func (s *LSym) NewFileInfo() *FileInfo {
505 panic(fmt.Sprintf("invalid use of LSym - NewFileInfo with Extra of type %T", *s.Extra))
508 s.Extra = new(interface{})
513 // File returns the *FileInfo associated with s, or else nil.
514 func (s *LSym) File() *FileInfo {
518 f, _ := (*s.Extra).(*FileInfo)
522 type InlMark struct {
523 // When unwinding from an instruction in an inlined body, mark
524 // where we should unwind to.
525 // id records the global inlining id of the inlined body.
526 // p records the location of an instruction in the parent (inliner) frame.
531 // Mark p as the instruction to set as the pc when
532 // "unwinding" the inlining global frame id. Usually it should be
533 // instruction with a file:line at the callsite, and occur
534 // just before the body of the inlined function.
535 func (fi *FuncInfo) AddInlMark(p *Prog, id int32) {
536 fi.InlMarks = append(fi.InlMarks, InlMark{p: p, id: id})
539 // Record the type symbol for an auto variable so that the linker
540 // an emit DWARF type information for the type.
541 func (fi *FuncInfo) RecordAutoType(gotype *LSym) {
543 fi.Autot = make(map[*LSym]struct{})
545 fi.Autot[gotype] = struct{}{}
548 //go:generate stringer -type ABI
550 // ABI is the calling convention of a text symbol.
554 // ABI0 is the stable stack-based ABI. It's important that the
555 // value of this is "0": we can't distinguish between
556 // references to data and ABI0 text symbols in assembly code,
557 // and hence this doesn't distinguish between symbols without
558 // an ABI and text symbols with ABI0.
561 // ABIInternal is the internal ABI that may change between Go
562 // versions. All Go functions use the internal ABI and the
563 // compiler generates wrappers for calls to and from other
570 // ParseABI converts from a string representation in 'abistr' to the
571 // corresponding ABI value. Second return value is TRUE if the
572 // abi string is recognized, FALSE otherwise.
573 func ParseABI(abistr string) (ABI, bool) {
580 return ABIInternal, true
584 // Attribute is a set of symbol attributes.
585 type Attribute uint32
588 AttrDuplicateOK Attribute = 1 << iota
598 // MakeTypelink means that the type should have an entry in the typelink table.
601 // ReflectMethod means the function may call reflect.Type.Method or
602 // reflect.Type.MethodByName. Matching is imprecise (as reflect.Type
603 // can be used through a custom interface), so ReflectMethod may be
604 // set in some cases when the reflect package is not called.
606 // Used by the linker to determine what methods can be pruned.
609 // Local means make the symbol local even when compiling Go code to reference Go
610 // symbols in other shared libraries, as in this mode symbols are global by
611 // default. "local" here means in the sense of the dynamic linker, i.e. not
612 // visible outside of the module (shared library or executable) that contains its
613 // definition. (When not compiling to support Go shared libraries, all symbols are
614 // local in this sense unless there is a cgo_export_* directive).
617 // For function symbols; indicates that the specified function was the
618 // target of an inline during compilation
621 // TopFrame means that this function is an entry point and unwinders should not
622 // keep unwinding beyond this frame.
625 // Indexed indicates this symbol has been assigned with an index (when using the
626 // new object file format).
629 // Only applied on type descriptor symbols, UsedInIface indicates this type is
630 // converted to an interface.
632 // Used by the linker to determine what methods can be pruned.
635 // ContentAddressable indicates this is a content-addressable symbol.
636 AttrContentAddressable
638 // ABI wrapper is set for compiler-generated text symbols that
639 // convert between ABI0 and ABIInternal calling conventions.
642 // attrABIBase is the value at which the ABI is encoded in
643 // Attribute. This must be last; all bits after this are
644 // assumed to be an ABI value.
646 // MUST BE LAST since all bits above this comprise the ABI.
650 func (a Attribute) DuplicateOK() bool { return a&AttrDuplicateOK != 0 }
651 func (a Attribute) MakeTypelink() bool { return a&AttrMakeTypelink != 0 }
652 func (a Attribute) CFunc() bool { return a&AttrCFunc != 0 }
653 func (a Attribute) NoSplit() bool { return a&AttrNoSplit != 0 }
654 func (a Attribute) Leaf() bool { return a&AttrLeaf != 0 }
655 func (a Attribute) OnList() bool { return a&AttrOnList != 0 }
656 func (a Attribute) ReflectMethod() bool { return a&AttrReflectMethod != 0 }
657 func (a Attribute) Local() bool { return a&AttrLocal != 0 }
658 func (a Attribute) Wrapper() bool { return a&AttrWrapper != 0 }
659 func (a Attribute) NeedCtxt() bool { return a&AttrNeedCtxt != 0 }
660 func (a Attribute) NoFrame() bool { return a&AttrNoFrame != 0 }
661 func (a Attribute) Static() bool { return a&AttrStatic != 0 }
662 func (a Attribute) WasInlined() bool { return a&AttrWasInlined != 0 }
663 func (a Attribute) TopFrame() bool { return a&AttrTopFrame != 0 }
664 func (a Attribute) Indexed() bool { return a&AttrIndexed != 0 }
665 func (a Attribute) UsedInIface() bool { return a&AttrUsedInIface != 0 }
666 func (a Attribute) ContentAddressable() bool { return a&AttrContentAddressable != 0 }
667 func (a Attribute) ABIWrapper() bool { return a&AttrABIWrapper != 0 }
669 func (a *Attribute) Set(flag Attribute, value bool) {
677 func (a Attribute) ABI() ABI { return ABI(a / attrABIBase) }
678 func (a *Attribute) SetABI(abi ABI) {
679 const mask = 1 // Only one ABI bit for now.
680 *a = (*a &^ (mask * attrABIBase)) | Attribute(abi)*attrABIBase
683 var textAttrStrings = [...]struct {
687 {bit: AttrDuplicateOK, s: "DUPOK"},
688 {bit: AttrMakeTypelink, s: ""},
689 {bit: AttrCFunc, s: "CFUNC"},
690 {bit: AttrNoSplit, s: "NOSPLIT"},
691 {bit: AttrLeaf, s: "LEAF"},
692 {bit: AttrOnList, s: ""},
693 {bit: AttrReflectMethod, s: "REFLECTMETHOD"},
694 {bit: AttrLocal, s: "LOCAL"},
695 {bit: AttrWrapper, s: "WRAPPER"},
696 {bit: AttrNeedCtxt, s: "NEEDCTXT"},
697 {bit: AttrNoFrame, s: "NOFRAME"},
698 {bit: AttrStatic, s: "STATIC"},
699 {bit: AttrWasInlined, s: ""},
700 {bit: AttrTopFrame, s: "TOPFRAME"},
701 {bit: AttrIndexed, s: ""},
702 {bit: AttrContentAddressable, s: ""},
703 {bit: AttrABIWrapper, s: "ABIWRAPPER"},
706 // TextAttrString formats a for printing in as part of a TEXT prog.
707 func (a Attribute) TextAttrString() string {
709 for _, x := range textAttrStrings {
721 a.SetABI(0) // Clear ABI so we don't print below.
724 s += fmt.Sprintf("UnknownAttribute(%d)|", a)
726 // Chop off trailing |, if present.
733 func (s *LSym) String() string {
737 // The compiler needs *LSym to be assignable to cmd/compile/internal/ssa.Sym.
738 func (*LSym) CanBeAnSSASym() {}
739 func (*LSym) CanBeAnSSAAux() {}
742 // Aux symbols for pcln
750 UsedFiles map[goobj.CUFileIndex]struct{} // file indices used while generating pcfile
751 InlTree InlTree // per-function inlining tree extracted from the global tree
757 Type objabi.RelocType
769 // RegArg provides spill/fill information for a register-resident argument
770 // to a function. These need spilling/filling in the safepoint/stackgrowth case.
771 // At the time of fill/spill, the offset must be adjusted by the architecture-dependent
772 // adjustment to hardware SP that occurs in a call instruction. E.g., for AMD64,
773 // at Offset+8 because the return address was pushed.
780 // Link holds the context for writing object code from a compiler
781 // to be linker input or for reading that input into the linker.
783 Headtype objabi.HeadType
792 Flag_locationlists bool
793 Retpoline bool // emit use of retpoline stubs for indirect jmp/call
796 Pkgpath string // the current package's import path, "" if unknown
797 hashmu sync.Mutex // protects hash, funchash
798 hash map[string]*LSym // name -> sym mapping
799 funchash map[string]*LSym // name -> sym mapping for ABIInternal syms
800 statichash map[string]*LSym // name -> sym mapping for static syms
801 PosTable src.PosTable
802 InlTree InlTree // global inlining tree used by gc/inl.go
803 DwFixups *DwarfFixupTable
804 Imports []goobj.ImportedPkg
805 DiagFunc func(string, ...interface{})
807 DebugInfo func(fn *LSym, info *LSym, curfn interface{}) ([]dwarf.Scope, dwarf.InlCalls) // if non-nil, curfn is a *gc.Node
808 GenAbstractFunc func(fn *LSym)
812 InParallel bool // parallel backend phase in effect
813 UseBASEntries bool // use Base Address Selection Entries in location lists and PC ranges
814 IsAsm bool // is the source assembly language, which may contain surprising idioms (e.g., call tables)
816 // state for writing objects
820 // ABIAliases are text symbols that should be aliased to all
821 // ABIs. These symbols may only be referenced and not defined
822 // by this object, since the need for an alias may appear in a
823 // different object than the definition. Hence, this
824 // information can't be carried in the symbol definition.
826 // TODO(austin): Replace this with ABI wrappers once the ABIs
830 // Constant symbols (e.g. $i64.*) are data symbols created late
831 // in the concurrent phase. To ensure a deterministic order, we
832 // add them to a separate list, sort at the end, and append it
836 // pkgIdx maps package path to index. The index is used for
837 // symbol reference in the object file.
838 pkgIdx map[string]int32
840 defs []*LSym // list of defined symbols in the current package
841 hashed64defs []*LSym // list of defined short (64-bit or less) hashed (content-addressable) symbols
842 hasheddefs []*LSym // list of defined hashed (content-addressable) symbols
843 nonpkgdefs []*LSym // list of defined non-package symbols
844 nonpkgrefs []*LSym // list of referenced non-package symbols
846 Fingerprint goobj.FingerprintType // fingerprint of symbol indices, to catch index mismatch
849 func (ctxt *Link) Diag(format string, args ...interface{}) {
851 ctxt.DiagFunc(format, args...)
854 func (ctxt *Link) Logf(format string, args ...interface{}) {
855 fmt.Fprintf(ctxt.Bso, format, args...)
859 func (ctxt *Link) SpillRegisterArgs(last *Prog, pa ProgAlloc) *Prog {
860 // Spill register args.
861 for _, ra := range ctxt.RegArgs {
862 spill := Appendp(last, pa)
864 spill.From.Type = TYPE_REG
865 spill.From.Reg = ra.Reg
872 func (ctxt *Link) UnspillRegisterArgs(last *Prog, pa ProgAlloc) *Prog {
873 // Unspill any spilled register args
874 for _, ra := range ctxt.RegArgs {
875 unspill := Appendp(last, pa)
876 unspill.As = ra.Unspill
877 unspill.From = ra.Addr
878 unspill.To.Type = TYPE_REG
879 unspill.To.Reg = ra.Reg
885 // The smallest possible offset from the hardware stack pointer to a local
886 // variable on the stack. Architectures that use a link register save its value
887 // on the stack in the function prologue and so always have a pointer between
888 // the hardware stack pointer and the local variable area.
889 func (ctxt *Link) FixedFrameSize() int64 {
890 switch ctxt.Arch.Family {
891 case sys.AMD64, sys.I386, sys.Wasm:
894 // PIC code on ppc64le requires 32 bytes of stack, and it's easier to
895 // just use that much stack always on ppc64x.
896 return int64(4 * ctxt.Arch.PtrSize)
898 return int64(ctxt.Arch.PtrSize)
902 // LinkArch is the definition of a single architecture.
903 type LinkArch struct {
906 Preprocess func(*Link, *LSym, ProgAlloc)
907 Assemble func(*Link, *LSym, ProgAlloc)
908 Progedit func(*Link, *Prog, ProgAlloc)
909 UnaryDst map[As]bool // Instruction takes one operand, a destination.
910 DWARFRegisters map[int16]int16