1 // Copyright 2009 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 amd64 6 7 import ( 8 "cmd/compile/internal/gc" 9 "cmd/internal/obj" 10 "cmd/internal/obj/x86" 11 ) 12 13 var ( 14 thechar int = '6' 15 thestring string = "amd64" 16 thelinkarch *obj.LinkArch = &x86.Linkamd64 17 ) 18 19 func linkarchinit() { 20 if obj.Getgoarch() == "amd64p32" { 21 thelinkarch = &x86.Linkamd64p32 22 gc.Thearch.Thelinkarch = thelinkarch 23 thestring = "amd64p32" 24 gc.Thearch.Thestring = "amd64p32" 25 } 26 } 27 28 var MAXWIDTH int64 = 1 << 50 29 30 var ( 31 addptr int = x86.AADDQ 32 movptr int = x86.AMOVQ 33 leaptr int = x86.ALEAQ 34 cmpptr int = x86.ACMPQ 35 ) 36 37 /* 38 * go declares several platform-specific type aliases: 39 * int, uint, and uintptr 40 */ 41 var typedefs = []gc.Typedef{ 42 gc.Typedef{"int", gc.TINT, gc.TINT64}, 43 gc.Typedef{"uint", gc.TUINT, gc.TUINT64}, 44 gc.Typedef{"uintptr", gc.TUINTPTR, gc.TUINT64}, 45 } 46 47 func betypeinit() { 48 gc.Widthptr = 8 49 gc.Widthint = 8 50 gc.Widthreg = 8 51 if obj.Getgoarch() == "amd64p32" { 52 gc.Widthptr = 4 53 gc.Widthint = 4 54 addptr = x86.AADDL 55 movptr = x86.AMOVL 56 leaptr = x86.ALEAL 57 cmpptr = x86.ACMPL 58 typedefs[0].Sameas = gc.TINT32 59 typedefs[1].Sameas = gc.TUINT32 60 typedefs[2].Sameas = gc.TUINT32 61 } 62 63 if gc.Ctxt.Flag_dynlink { 64 gc.Thearch.ReservedRegs = append(gc.Thearch.ReservedRegs, x86.REG_R15) 65 } 66 } 67 68 func Main() { 69 if obj.Getgoos() == "nacl" { 70 resvd = append(resvd, x86.REG_BP, x86.REG_R15) 71 } else if obj.Framepointer_enabled != 0 { 72 resvd = append(resvd, x86.REG_BP) 73 } 74 75 gc.Thearch.Thechar = thechar 76 gc.Thearch.Thestring = thestring 77 gc.Thearch.Thelinkarch = thelinkarch 78 gc.Thearch.Typedefs = typedefs 79 gc.Thearch.REGSP = x86.REGSP 80 gc.Thearch.REGCTXT = x86.REGCTXT 81 gc.Thearch.REGCALLX = x86.REG_BX 82 gc.Thearch.REGCALLX2 = x86.REG_AX 83 gc.Thearch.REGRETURN = x86.REG_AX 84 gc.Thearch.REGMIN = x86.REG_AX 85 gc.Thearch.REGMAX = x86.REG_R15 86 gc.Thearch.FREGMIN = x86.REG_X0 87 gc.Thearch.FREGMAX = x86.REG_X15 88 gc.Thearch.MAXWIDTH = MAXWIDTH 89 gc.Thearch.ReservedRegs = resvd 90 91 gc.Thearch.AddIndex = addindex 92 gc.Thearch.Betypeinit = betypeinit 93 gc.Thearch.Cgen_bmul = cgen_bmul 94 gc.Thearch.Cgen_hmul = cgen_hmul 95 gc.Thearch.Cgen_shift = cgen_shift 96 gc.Thearch.Clearfat = clearfat 97 gc.Thearch.Defframe = defframe 98 gc.Thearch.Dodiv = dodiv 99 gc.Thearch.Excise = excise 100 gc.Thearch.Expandchecks = expandchecks 101 gc.Thearch.Getg = getg 102 gc.Thearch.Gins = gins 103 gc.Thearch.Ginsboolval = ginsboolval 104 gc.Thearch.Ginscmp = ginscmp 105 gc.Thearch.Ginscon = ginscon 106 gc.Thearch.Ginsnop = ginsnop 107 gc.Thearch.Gmove = gmove 108 gc.Thearch.Linkarchinit = linkarchinit 109 gc.Thearch.Peep = peep 110 gc.Thearch.Proginfo = proginfo 111 gc.Thearch.Regtyp = regtyp 112 gc.Thearch.Sameaddr = sameaddr 113 gc.Thearch.Smallindir = smallindir 114 gc.Thearch.Stackaddr = stackaddr 115 gc.Thearch.Blockcopy = blockcopy 116 gc.Thearch.Sudoaddable = sudoaddable 117 gc.Thearch.Sudoclean = sudoclean 118 gc.Thearch.Excludedregs = excludedregs 119 gc.Thearch.RtoB = RtoB 120 gc.Thearch.FtoB = FtoB 121 gc.Thearch.BtoR = BtoR 122 gc.Thearch.BtoF = BtoF 123 gc.Thearch.Optoas = optoas 124 gc.Thearch.Doregbits = doregbits 125 gc.Thearch.Regnames = regnames 126 127 gc.Main() 128 gc.Exit(0) 129 } 130