Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 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 gc |
| 6 | |
| 7 | import ( |
Michael Pratt | a4e31d4 | 2016-03-12 14:07:40 -0800 | [diff] [blame] | 8 | "cmd/compile/internal/ssa" |
Matthew Dempsky | 4b7e36c | 2016-04-06 21:45:29 -0700 | [diff] [blame] | 9 | "cmd/internal/bio" |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 10 | "cmd/internal/obj" |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 11 | ) |
| 12 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 13 | const ( |
Rob Pike | 24a43e6 | 2015-03-05 10:39:23 -0800 | [diff] [blame] | 14 | UINF = 100 |
Rob Pike | 24a43e6 | 2015-03-05 10:39:23 -0800 | [diff] [blame] | 15 | BADWIDTH = -1000000000 |
| 16 | MaxStackVarSize = 10 * 1024 * 1024 |
| 17 | ) |
| 18 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 19 | type Pkg struct { |
David Chase | 8eec2bb | 2016-03-11 00:10:52 -0500 | [diff] [blame] | 20 | Name string // package name, e.g. "sys" |
| 21 | Path string // string literal used in import statement, e.g. "runtime/internal/sys" |
David Crawshaw | f120936 | 2016-03-31 10:02:10 -0400 | [diff] [blame] | 22 | Pathsym *obj.LSym |
Russ Cox | cdb7d7d | 2015-03-05 13:57:36 -0500 | [diff] [blame] | 23 | Prefix string // escaped path for use in symbol table |
Marvin Stenger | e03c789 | 2015-09-08 05:46:31 +0200 | [diff] [blame] | 24 | Imported bool // export data of this package was parsed |
Marvin Stenger | e03c789 | 2015-09-08 05:46:31 +0200 | [diff] [blame] | 25 | Direct bool // imported directly |
Russ Cox | d0b59de | 2015-03-02 16:21:15 -0500 | [diff] [blame] | 26 | Syms map[string]*Sym |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 27 | } |
| 28 | |
Matthew Dempsky | cca4ddb | 2016-04-05 12:48:49 -0700 | [diff] [blame] | 29 | // Sym represents an object name. Most commonly, this is a Go identifier naming |
| 30 | // an object declared within a package, but Syms are also used to name internal |
| 31 | // synthesized objects. |
| 32 | // |
| 33 | // As a special exception, field and method names that are exported use the Sym |
| 34 | // associated with localpkg instead of the package that declared them. This |
| 35 | // allows using Sym pointer equality to test for Go identifier uniqueness when |
| 36 | // handling selector expressions. |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 37 | type Sym struct { |
Robert Griesemer | 37c2972 | 2016-03-01 16:37:20 -0800 | [diff] [blame] | 38 | Flags SymFlags |
Matthew Dempsky | 071e43a | 2016-02-26 01:37:28 -0800 | [diff] [blame] | 39 | Link *Sym |
Russ Cox | cdb7d7d | 2015-03-05 13:57:36 -0500 | [diff] [blame] | 40 | Importdef *Pkg // where imported definition was found |
| 41 | Linkname string // link name |
| 42 | |
| 43 | // saved and restored by dcopy |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 44 | Pkg *Pkg |
Russ Cox | cdb7d7d | 2015-03-05 13:57:36 -0500 | [diff] [blame] | 45 | Name string // variable name |
| 46 | Def *Node // definition: ONAME OTYPE OPACK or OLITERAL |
Russ Cox | cdb7d7d | 2015-03-05 13:57:36 -0500 | [diff] [blame] | 47 | Block int32 // blocknumber to catch redeclaration |
| 48 | Lastlineno int32 // last declaration for diagnostic |
Robert Griesemer | 157f069 | 2016-03-10 15:07:08 -0800 | [diff] [blame] | 49 | |
| 50 | Label *Label // corresponding label (ephemeral) |
| 51 | Origpkg *Pkg // original package for . import |
| 52 | Lsym *obj.LSym |
| 53 | Fsym *Sym // funcsym |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 54 | } |
| 55 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 56 | type Label struct { |
Robert Griesemer | def9c0b | 2016-03-10 20:35:27 -0800 | [diff] [blame] | 57 | Def *Node |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 58 | } |
| 59 | |
Robert Griesemer | 37c2972 | 2016-03-01 16:37:20 -0800 | [diff] [blame] | 60 | type SymFlags uint8 |
| 61 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 62 | const ( |
Robert Griesemer | 37c2972 | 2016-03-01 16:37:20 -0800 | [diff] [blame] | 63 | SymExport SymFlags = 1 << iota // to be exported |
| 64 | SymPackage |
| 65 | SymExported // already written out by export |
| 66 | SymUniq |
| 67 | SymSiggen |
| 68 | SymAsm |
| 69 | SymAlgGen |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 70 | ) |
| 71 | |
Robert Griesemer | cd7d738 | 2015-10-26 14:57:36 -0700 | [diff] [blame] | 72 | // The Class of a variable/function describes the "storage class" |
| 73 | // of a variable or function. During parsing, storage classes are |
| 74 | // called declaration contexts. |
| 75 | type Class uint8 |
| 76 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 77 | const ( |
Robert Griesemer | cd7d738 | 2015-10-26 14:57:36 -0700 | [diff] [blame] | 78 | Pxxx Class = iota |
| 79 | PEXTERN // global variable |
| 80 | PAUTO // local variables |
Russ Cox | b6dc3e6 | 2016-05-25 01:33:24 -0400 | [diff] [blame] | 81 | PAUTOHEAP // local variable or parameter moved to heap |
Robert Griesemer | cd7d738 | 2015-10-26 14:57:36 -0700 | [diff] [blame] | 82 | PPARAM // input arguments |
| 83 | PPARAMOUT // output results |
Robert Griesemer | cd7d738 | 2015-10-26 14:57:36 -0700 | [diff] [blame] | 84 | PFUNC // global function |
Russ Cox | cdb7d7d | 2015-03-05 13:57:36 -0500 | [diff] [blame] | 85 | |
| 86 | PDISCARD // discard during parse of duplicate import |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 87 | ) |
| 88 | |
Jeremy Jackins | 6327e8d | 2015-10-22 09:51:12 +0900 | [diff] [blame] | 89 | // note this is the runtime representation |
| 90 | // of the compilers arrays. |
| 91 | // |
| 92 | // typedef struct |
| 93 | // { // must not move anything |
| 94 | // uchar array[8]; // pointer to data |
| 95 | // uchar nel[4]; // number of elements |
| 96 | // uchar cap[4]; // allocated number of elements |
| 97 | // } Array; |
Dave Cheney | 584978f | 2016-09-16 00:33:29 +1000 | [diff] [blame] | 98 | var array_array int // runtime offsetof(Array,array) - same for String |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 99 | |
Dave Cheney | 584978f | 2016-09-16 00:33:29 +1000 | [diff] [blame] | 100 | var array_nel int // runtime offsetof(Array,nel) - same for String |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 101 | |
Dave Cheney | 584978f | 2016-09-16 00:33:29 +1000 | [diff] [blame] | 102 | var array_cap int // runtime offsetof(Array,cap) |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 103 | |
| 104 | var sizeof_Array int // runtime sizeof(Array) |
| 105 | |
Jeremy Jackins | 6327e8d | 2015-10-22 09:51:12 +0900 | [diff] [blame] | 106 | // note this is the runtime representation |
| 107 | // of the compilers strings. |
| 108 | // |
| 109 | // typedef struct |
| 110 | // { // must not move anything |
| 111 | // uchar array[8]; // pointer to data |
| 112 | // uchar nel[4]; // number of elements |
| 113 | // } String; |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 114 | var sizeof_String int // runtime sizeof(String) |
| 115 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 116 | var pragcgobuf string |
| 117 | |
| 118 | var infile string |
| 119 | |
| 120 | var outfile string |
Russ Cox | feb6131 | 2016-04-26 21:50:59 -0400 | [diff] [blame] | 121 | var linkobj string |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 122 | |
Dave Cheney | 8f2edf1 | 2016-04-08 19:14:03 +1000 | [diff] [blame] | 123 | var bout *bio.Writer |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 124 | |
| 125 | var nerrors int |
| 126 | |
| 127 | var nsavederrors int |
| 128 | |
| 129 | var nsyntaxerrors int |
| 130 | |
Josh Bleecher Snyder | 2b063bd | 2015-05-14 19:33:31 -0700 | [diff] [blame] | 131 | var decldepth int32 |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 132 | |
Matthew Dempsky | 980ab12 | 2016-04-13 18:37:18 -0700 | [diff] [blame] | 133 | var safemode bool |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 134 | |
Matthew Dempsky | 980ab12 | 2016-04-13 18:37:18 -0700 | [diff] [blame] | 135 | var nolocalimports bool |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 136 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 137 | var Debug [256]int |
| 138 | |
| 139 | var debugstr string |
| 140 | |
| 141 | var Debug_checknil int |
Russ Cox | 4224d81 | 2015-03-20 00:06:10 -0400 | [diff] [blame] | 142 | var Debug_typeassert int |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 143 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 144 | var localpkg *Pkg // package being compiled |
| 145 | |
| 146 | var importpkg *Pkg // package being imported |
| 147 | |
Michel Lespinasse | 859b63c | 2016-03-18 17:21:33 -0700 | [diff] [blame] | 148 | var itabpkg *Pkg // fake pkg for itab entries |
Michel Lespinasse | f00bbd5 | 2016-03-17 06:18:13 -0700 | [diff] [blame] | 149 | |
| 150 | var itablinkpkg *Pkg // fake package for runtime itab entries |
| 151 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 152 | var Runtimepkg *Pkg // package runtime |
| 153 | |
| 154 | var racepkg *Pkg // package runtime/race |
| 155 | |
Ian Lance Taylor | 0c69f13 | 2015-10-21 07:04:10 -0700 | [diff] [blame] | 156 | var msanpkg *Pkg // package runtime/msan |
| 157 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 158 | var typepkg *Pkg // fake package for runtime type info (headers) |
| 159 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 160 | var unsafepkg *Pkg // package unsafe |
| 161 | |
| 162 | var trackpkg *Pkg // fake package for field tracking |
| 163 | |
Keith Randall | 60fd32a | 2016-04-19 08:31:04 -0700 | [diff] [blame] | 164 | var mappkg *Pkg // fake package for map zero value |
| 165 | var zerosize int64 |
| 166 | |
Marvin Stenger | 8e7a3ea | 2015-09-24 23:21:18 +0200 | [diff] [blame] | 167 | var Tptr EType // either TPTR32 or TPTR64 |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 168 | |
| 169 | var myimportpath string |
| 170 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 171 | var localimport string |
| 172 | |
| 173 | var asmhdr string |
| 174 | |
Dave Cheney | 584978f | 2016-09-16 00:33:29 +1000 | [diff] [blame] | 175 | var simtype [NTYPE]EType |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 176 | |
Josh Bleecher Snyder | 25da594 | 2015-03-01 07:54:01 +0000 | [diff] [blame] | 177 | var ( |
Josh Bleecher Snyder | 25da594 | 2015-03-01 07:54:01 +0000 | [diff] [blame] | 178 | isforw [NTYPE]bool |
Dave Cheney | 584978f | 2016-09-16 00:33:29 +1000 | [diff] [blame] | 179 | isInt [NTYPE]bool |
| 180 | isFloat [NTYPE]bool |
| 181 | isComplex [NTYPE]bool |
Josh Bleecher Snyder | 25da594 | 2015-03-01 07:54:01 +0000 | [diff] [blame] | 182 | issimple [NTYPE]bool |
| 183 | ) |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 184 | |
Josh Bleecher Snyder | 25da594 | 2015-03-01 07:54:01 +0000 | [diff] [blame] | 185 | var ( |
| 186 | okforeq [NTYPE]bool |
| 187 | okforadd [NTYPE]bool |
| 188 | okforand [NTYPE]bool |
| 189 | okfornone [NTYPE]bool |
| 190 | okforcmp [NTYPE]bool |
| 191 | okforbool [NTYPE]bool |
| 192 | okforcap [NTYPE]bool |
| 193 | okforlen [NTYPE]bool |
| 194 | okforarith [NTYPE]bool |
| 195 | okforconst [NTYPE]bool |
| 196 | ) |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 197 | |
Josh Bleecher Snyder | 25da594 | 2015-03-01 07:54:01 +0000 | [diff] [blame] | 198 | var ( |
| 199 | okfor [OEND][]bool |
| 200 | iscmp [OEND]bool |
| 201 | ) |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 202 | |
Dave Cheney | 584978f | 2016-09-16 00:33:29 +1000 | [diff] [blame] | 203 | var minintval [NTYPE]*Mpint |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 204 | |
Dave Cheney | 584978f | 2016-09-16 00:33:29 +1000 | [diff] [blame] | 205 | var maxintval [NTYPE]*Mpint |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 206 | |
| 207 | var minfltval [NTYPE]*Mpflt |
| 208 | |
| 209 | var maxfltval [NTYPE]*Mpflt |
| 210 | |
Ian Lance Taylor | f444b8a | 2016-03-09 20:29:21 -0800 | [diff] [blame] | 211 | var xtop []*Node |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 212 | |
Robert Griesemer | 3d3bc88 | 2015-08-12 14:29:50 -0700 | [diff] [blame] | 213 | var exportlist []*Node |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 214 | |
Håvard Haugen | 391cc54 | 2015-09-06 22:38:49 +0200 | [diff] [blame] | 215 | var importlist []*Node // imported functions and methods with inlinable bodies |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 216 | |
Robert Griesemer | a2119ac | 2015-10-05 16:33:53 -0700 | [diff] [blame] | 217 | var funcsyms []*Node |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 218 | |
Robert Griesemer | cd7d738 | 2015-10-26 14:57:36 -0700 | [diff] [blame] | 219 | var dclcontext Class // PEXTERN/PAUTO |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 220 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 221 | var statuniqgen int // name generator for static temps |
| 222 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 223 | var iota_ int32 |
| 224 | |
Ian Lance Taylor | f444b8a | 2016-03-09 20:29:21 -0800 | [diff] [blame] | 225 | var lastconst []*Node |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 226 | |
| 227 | var lasttype *Node |
| 228 | |
| 229 | var Maxarg int64 |
| 230 | |
| 231 | var Stksize int64 // stack size for current frame |
| 232 | |
| 233 | var stkptrsize int64 // prefix of stack containing pointers |
| 234 | |
Håvard Haugen | 2594664 | 2015-09-07 22:19:30 +0200 | [diff] [blame] | 235 | var hasdefer bool // flag that curfn has defer statement |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 236 | |
| 237 | var Curfn *Node |
| 238 | |
| 239 | var Widthptr int |
| 240 | |
| 241 | var Widthint int |
| 242 | |
| 243 | var Widthreg int |
| 244 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 245 | var nblank *Node |
| 246 | |
Håvard Haugen | dc3540d | 2015-08-30 23:56:40 +0200 | [diff] [blame] | 247 | var typecheckok bool |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 248 | |
Matthew Dempsky | 980ab12 | 2016-04-13 18:37:18 -0700 | [diff] [blame] | 249 | var compiling_runtime bool |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 250 | |
| 251 | var compiling_wrappers int |
| 252 | |
Matthew Dempsky | 980ab12 | 2016-04-13 18:37:18 -0700 | [diff] [blame] | 253 | var use_writebarrier bool |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 254 | |
Matthew Dempsky | 980ab12 | 2016-04-13 18:37:18 -0700 | [diff] [blame] | 255 | var pure_go bool |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 256 | |
| 257 | var flag_installsuffix string |
| 258 | |
Matthew Dempsky | 980ab12 | 2016-04-13 18:37:18 -0700 | [diff] [blame] | 259 | var flag_race bool |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 260 | |
Matthew Dempsky | 980ab12 | 2016-04-13 18:37:18 -0700 | [diff] [blame] | 261 | var flag_msan bool |
Ian Lance Taylor | 0c69f13 | 2015-10-21 07:04:10 -0700 | [diff] [blame] | 262 | |
Matthew Dempsky | 980ab12 | 2016-04-13 18:37:18 -0700 | [diff] [blame] | 263 | var flag_largemodel bool |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 264 | |
Ian Lance Taylor | 9e902f0 | 2015-10-20 10:00:07 -0700 | [diff] [blame] | 265 | // Whether we are adding any sort of code instrumentation, such as |
| 266 | // when the race detector is enabled. |
| 267 | var instrumenting bool |
| 268 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 269 | var debuglive int |
| 270 | |
| 271 | var Ctxt *obj.Link |
| 272 | |
Matthew Dempsky | 980ab12 | 2016-04-13 18:37:18 -0700 | [diff] [blame] | 273 | var writearchive bool |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 274 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 275 | var Nacl bool |
| 276 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 277 | var Pc *obj.Prog |
| 278 | |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 279 | var nodfp *Node |
| 280 | |
Dave Cheney | 584978f | 2016-09-16 00:33:29 +1000 | [diff] [blame] | 281 | var disable_checknil int |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 282 | |
Jeremy Jackins | 6327e8d | 2015-10-22 09:51:12 +0900 | [diff] [blame] | 283 | // interface to back end |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 284 | |
| 285 | const ( |
Russ Cox | cdb7d7d | 2015-03-05 13:57:36 -0500 | [diff] [blame] | 286 | // Pseudo-op, like TEXT, GLOBL, TYPE, PCDATA, FUNCDATA. |
| 287 | Pseudo = 1 << 1 |
| 288 | |
| 289 | // There's nothing to say about the instruction, |
| 290 | // but it's still okay to see. |
| 291 | OK = 1 << 2 |
| 292 | |
| 293 | // Size of right-side write, or right-side read if no write. |
| 294 | SizeB = 1 << 3 |
| 295 | SizeW = 1 << 4 |
| 296 | SizeL = 1 << 5 |
| 297 | SizeQ = 1 << 6 |
| 298 | SizeF = 1 << 7 |
| 299 | SizeD = 1 << 8 |
| 300 | |
| 301 | // Left side (Prog.from): address taken, read, write. |
| 302 | LeftAddr = 1 << 9 |
| 303 | LeftRead = 1 << 10 |
| 304 | LeftWrite = 1 << 11 |
| 305 | |
| 306 | // Register in middle (Prog.reg); only ever read. (arm, ppc64) |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 307 | RegRead = 1 << 12 |
| 308 | CanRegRead = 1 << 13 |
Russ Cox | cdb7d7d | 2015-03-05 13:57:36 -0500 | [diff] [blame] | 309 | |
| 310 | // Right side (Prog.to): address taken, read, write. |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 311 | RightAddr = 1 << 14 |
| 312 | RightRead = 1 << 15 |
| 313 | RightWrite = 1 << 16 |
Russ Cox | cdb7d7d | 2015-03-05 13:57:36 -0500 | [diff] [blame] | 314 | |
| 315 | // Instruction kinds |
| 316 | Move = 1 << 17 // straight move |
| 317 | Conv = 1 << 18 // size conversion |
| 318 | Cjmp = 1 << 19 // conditional jump |
| 319 | Break = 1 << 20 // breaks control flow (no fallthrough) |
| 320 | Call = 1 << 21 // function call |
| 321 | Jump = 1 << 22 // jump |
| 322 | Skip = 1 << 23 // data instruction |
| 323 | |
| 324 | // Set, use, or kill of carry bit. |
| 325 | // Kill means we never look at the carry bit after this kind of instruction. |
David Chase | 8eec2bb | 2016-03-11 00:10:52 -0500 | [diff] [blame] | 326 | // Originally for understanding ADC, RCR, and so on, but now also |
| 327 | // tracks set, use, and kill of the zero and overflow bits as well. |
| 328 | // TODO rename to {Set,Use,Kill}Flags |
Russ Cox | cdb7d7d | 2015-03-05 13:57:36 -0500 | [diff] [blame] | 329 | SetCarry = 1 << 24 |
| 330 | UseCarry = 1 << 25 |
| 331 | KillCarry = 1 << 26 |
| 332 | |
| 333 | // Special cases for register use. (amd64, 386) |
| 334 | ShiftCX = 1 << 27 // possible shift by CX |
| 335 | ImulAXDX = 1 << 28 // possible multiply into DX:AX |
| 336 | |
| 337 | // Instruction updates whichever of from/to is type D_OREG. (ppc64) |
| 338 | PostInc = 1 << 29 |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 339 | ) |
| 340 | |
| 341 | type Arch struct { |
Matthew Dempsky | c6e11fe | 2016-04-06 12:01:40 -0700 | [diff] [blame] | 342 | LinkArch *obj.LinkArch |
| 343 | |
Matthew Dempsky | 1f2930c | 2016-09-15 16:33:11 -0700 | [diff] [blame] | 344 | REGSP int |
Matthew Dempsky | 1f2930c | 2016-09-15 16:33:11 -0700 | [diff] [blame] | 345 | MAXWIDTH int64 |
Russ Cox | b115c35 | 2015-03-18 17:26:36 -0400 | [diff] [blame] | 346 | |
Matthew Dempsky | 544010a | 2016-09-15 16:37:17 -0700 | [diff] [blame] | 347 | Defframe func(*obj.Prog) |
| 348 | Proginfo func(*obj.Prog) // fills in Prog.Info |
| 349 | Use387 bool // should 8g use 387 FP instructions instead of sse2. |
Michael Pratt | a4e31d4 | 2016-03-12 14:07:40 -0800 | [diff] [blame] | 350 | |
Michael Pratt | a4e31d4 | 2016-03-12 14:07:40 -0800 | [diff] [blame] | 351 | // SSAMarkMoves marks any MOVXconst ops that need to avoid clobbering flags. |
| 352 | SSAMarkMoves func(*SSAGenState, *ssa.Block) |
| 353 | |
| 354 | // SSAGenValue emits Prog(s) for the Value. |
| 355 | SSAGenValue func(*SSAGenState, *ssa.Value) |
| 356 | |
| 357 | // SSAGenBlock emits end-of-block Progs. SSAGenValue should be called |
| 358 | // for all values in the block before SSAGenBlock. |
| 359 | SSAGenBlock func(s *SSAGenState, b, next *ssa.Block) |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | var pcloc int32 |
| 363 | |
| 364 | var Thearch Arch |
| 365 | |
| 366 | var Newproc *Node |
| 367 | |
| 368 | var Deferproc *Node |
| 369 | |
| 370 | var Deferreturn *Node |
| 371 | |
Dave Cheney | 584978f | 2016-09-16 00:33:29 +1000 | [diff] [blame] | 372 | var panicindex *Node |
Russ Cox | 8c195bd | 2015-02-13 14:40:36 -0500 | [diff] [blame] | 373 | |
| 374 | var panicslice *Node |
| 375 | |
David Chase | 18559e2 | 2015-10-28 13:55:46 -0400 | [diff] [blame] | 376 | var panicdivide *Node |
| 377 | |
Keith Randall | 8c5bfcc | 2015-09-18 15:11:30 -0700 | [diff] [blame] | 378 | var growslice *Node |
| 379 | |
Keith Randall | 5ba3194 | 2016-01-25 17:06:54 -0800 | [diff] [blame] | 380 | var writebarrierptr *Node |
| 381 | var typedmemmove *Node |
Keith Randall | 8c5bfcc | 2015-09-18 15:11:30 -0700 | [diff] [blame] | 382 | |
| 383 | var panicdottype *Node |