1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef MAPLEBE_INCLUDE_CG_ASM_INFO_H 17 #define MAPLEBE_INCLUDE_CG_ASM_INFO_H 18 19 #include "maple_string.h" 20 21 namespace maplebe { 22 enum AsmLabel : uint8 { 23 kAsmGlbl, 24 kAsmLocal, 25 kAsmWeak, 26 kAsmBss, 27 kAsmComm, 28 kAsmData, 29 kAsmAlign, 30 kAsmSyname, 31 kAsmZero, 32 kAsmByte, 33 kAsmShort, 34 kAsmValue, 35 kAsmLong, 36 kAsmQuad, 37 kAsmSize, 38 kAsmType, 39 kAsmText, 40 kAsmHidden 41 }; 42 43 class AsmInfo { 44 public: GetCmnt()45 const MapleString &GetCmnt() const 46 { 47 return asmCmnt; 48 } 49 GetAtobt()50 const MapleString &GetAtobt() const 51 { 52 return asmAtObt; 53 } 54 GetFile()55 const MapleString &GetFile() const 56 { 57 return asmFile; 58 } 59 GetSection()60 const MapleString &GetSection() const 61 { 62 return asmSection; 63 } 64 GetRodata()65 const MapleString &GetRodata() const 66 { 67 return asmRodata; 68 } 69 GetGlobal()70 const MapleString &GetGlobal() const 71 { 72 return asmGlobal; 73 } 74 GetLocal()75 const MapleString &GetLocal() const 76 { 77 return asmLocal; 78 } 79 GetWeak()80 const MapleString &GetWeak() const 81 { 82 return asmWeak; 83 } 84 GetBss()85 const MapleString &GetBss() const 86 { 87 return asmBss; 88 } 89 GetComm()90 const MapleString &GetComm() const 91 { 92 return asmComm; 93 } 94 GetData()95 const MapleString &GetData() const 96 { 97 return asmData; 98 } 99 GetAlign()100 const MapleString &GetAlign() const 101 { 102 return asmAlign; 103 } 104 GetZero()105 const MapleString &GetZero() const 106 { 107 return asmZero; 108 } 109 GetByte()110 const MapleString &GetByte() const 111 { 112 return asmByte; 113 } 114 GetShort()115 const MapleString &GetShort() const 116 { 117 return asmShort; 118 } 119 GetValue()120 const MapleString &GetValue() const 121 { 122 return asmValue; 123 } 124 GetLong()125 const MapleString &GetLong() const 126 { 127 return asmLong; 128 } 129 GetQuad()130 const MapleString &GetQuad() const 131 { 132 return asmQuad; 133 } 134 GetSize()135 const MapleString &GetSize() const 136 { 137 return asmSize; 138 } 139 GetType()140 const MapleString &GetType() const 141 { 142 return asmType; 143 } 144 GetHidden()145 const MapleString &GetHidden() const 146 { 147 return asmHidden; 148 } 149 GetText()150 const MapleString &GetText() const 151 { 152 return asmText; 153 } 154 GetSet()155 const MapleString &GetSet() const 156 { 157 return asmSet; 158 } 159 GetWeakref()160 const MapleString &GetWeakref() const 161 { 162 return asmWeakref; 163 } 164 AsmInfo(MemPool & memPool)165 explicit AsmInfo(MemPool &memPool) 166 #if TARGX86 || TARGX86_64 167 : asmCmnt("\t//\t", &memPool), 168 #elif TARGARM32 169 : asmCmnt("\t@\t", &memPool), 170 #else 171 : asmCmnt("\t#\t", &memPool), 172 #endif 173 174 asmAtObt("\t%object\t", &memPool), 175 asmFile("\t.file\t", &memPool), 176 asmSection("\t.section\t", &memPool), 177 asmRodata(".rodata\t", &memPool), 178 asmGlobal("\t.global\t", &memPool), 179 asmLocal("\t.local\t", &memPool), 180 asmWeak("\t.weak\t", &memPool), 181 asmBss("\t.bss\t", &memPool), 182 asmComm("\t.comm\t", &memPool), 183 asmData("\t.data\t", &memPool), 184 asmAlign("\t.align\t", &memPool), 185 asmZero("\t.zero\t", &memPool), 186 asmByte("\t.byte\t", &memPool), 187 asmShort("\t.short\t", &memPool), 188 #ifdef TARGARM32 189 asmValue("\t.short\t", &memPool), 190 #else 191 asmValue("\t.value\t", &memPool), 192 #endif 193 #ifdef TARGARM32 194 asmLong("\t.word\t", &memPool), 195 #else 196 asmLong("\t.long\t", &memPool), 197 #endif 198 asmQuad("\t.quad\t", &memPool), 199 asmSize("\t.size\t", &memPool), 200 asmType("\t.type\t", &memPool), 201 asmHidden("\t.hidden\t", &memPool), 202 asmText("\t.text\t", &memPool), 203 asmSet("\t.set\t", &memPool), 204 asmWeakref("\t.weakref\t", &memPool) 205 { 206 } 207 208 ~AsmInfo() = default; 209 210 private: 211 MapleString asmCmnt; 212 MapleString asmAtObt; 213 MapleString asmFile; 214 MapleString asmSection; 215 MapleString asmRodata; 216 MapleString asmGlobal; 217 MapleString asmLocal; 218 MapleString asmWeak; 219 MapleString asmBss; 220 MapleString asmComm; 221 MapleString asmData; 222 MapleString asmAlign; 223 MapleString asmZero; 224 MapleString asmByte; 225 MapleString asmShort; 226 MapleString asmValue; 227 MapleString asmLong; 228 MapleString asmQuad; 229 MapleString asmSize; 230 MapleString asmType; 231 MapleString asmHidden; 232 MapleString asmText; 233 MapleString asmSet; 234 MapleString asmWeakref; 235 }; 236 } /* namespace maplebe */ 237 238 #endif /* MAPLEBE_INCLUDE_CG_ASM_INFO_H */ 239