| 1 |
{ |
| 2 |
"fileTypes": ["S", "s", "riscv", "asm"], |
| 3 |
"keyEquivalent": "^~M", |
| 4 |
"name": "riscv", |
| 5 |
"patterns": [ |
| 6 |
{ |
| 7 |
"comment": "ok actually this are instructions, but one also could call them funtions…", |
| 8 |
"match": "\\b(la|lb|lh|lw|ld|nop|li|mv|not|neg|negw|sext\\.w|seqz|snez|sltz|sgtz|beqz|bnez|blez|bgez|bltz|bgtz|bgt|ble|bgtu|bleu|j|jal|jr|ret|call|tail|fence|csr[r|w|s|c]|csr[w|s|c]i)\\b", |
| 9 |
"name": "support.function.pseudo.riscv" |
| 10 |
}, |
| 11 |
{ |
| 12 |
"match": "\\b(add|addw|auipc|lui|jalr|beq|bne|blt|bge|bltu|bgeu|lb|lh|lw|ld|lbu|lhu|sb|sh|sw|sd|addi|addiw|slti|sltiu|xori|ori|andi|slli|slliw|srli|srliw|srai|sraiw|sub|subw|sll|sllw|slt|sltu|xor|srl|srlw|sra|sraw|or|and|fence|fence\\.i|csrrw|csrrs|csrrc|csrrwi|csrrsi|csrrci)\\b", |
| 13 |
"name": "support.function.riscv" |
| 14 |
}, |
| 15 |
{ |
| 16 |
"comment": "priviledged instructions", |
| 17 |
"match": "\\b(ecall|ebreak|sfence\\.vma|mret|sret|uret|wfi)\\b", |
| 18 |
"name": "support.function.riscv.privileged" |
| 19 |
}, |
| 20 |
{ |
| 21 |
"comment": "M extension (multiplication and division)", |
| 22 |
"match": "\\b(mul|mulh|mulhsu|mulhu|div|divu|rem|remu|mulw|divw|divuw|remw|remuw)\\b", |
| 23 |
"name": "support.function.riscv.m" |
| 24 |
}, |
| 25 |
{ |
| 26 |
"comment": "C extension (compressed instructions)", |
| 27 |
"match": "\\b(c\\.addi4spn|c\\.fld|c\\.lq|c\\.lw|c\\.flw|c\\.ld|c\\.fsd|c\\.sq|c\\.sw|c\\.fsw|c\\.sd|c\\.nop|c\\.addi|c\\.jal|c\\.addiw|c\\.li|c\\.addi16sp|c\\.lui|c\\.srli|c\\.srli64|c\\.srai|c\\.srai64|c\\.andi|c\\.sub|c\\.xor|c\\.or|c\\.and|c\\.subw|c\\.addw|c\\.j|c\\.beqz|c\\.bnez)\\b", |
| 28 |
"name": "support.function.riscv.c" |
| 29 |
}, |
| 30 |
{ |
| 31 |
"comment": "A extension (atomic instructions)", |
| 32 |
"match": "\\b(lr\\.[w|d]|sc\\.[w|d]|amoswap\\.[w|d]|amoadd\\.[w|d]|amoxor\\.[w|d]|amoand\\.[w|d]|amoor\\.[w|d]|amomin\\.[w|d]|amomax\\.[w|d]|amominu\\.[w|d]|amomaxu\\.[w|d])\\b", |
| 33 |
"name": "support.function.riscv.a" |
| 34 |
}, |
| 35 |
{ |
| 36 |
"comment": "F extension (single precision floating point)", |
| 37 |
"match": "\\b(flw|fsw|fmadd\\.s|fmsub\\.s|fnmsub\\.s|fnmadd\\.s|fadd\\.s|fsub\\.s|fmul\\.s|fdiv\\.s|fsqrt\\.s|fsgnj\\.s|fsgnjn\\.s|fsgnjx\\.s|fmin\\.s|fmax\\.s|fcvt\\.w\\.s|fcvt\\.wu\\.s|fmv\\.x\\.w|feq\\.s|flt\\.s|fle\\.s|fclass\\.s|fcvt\\.s\\.w|fcvt\\.s\\.wu|fmv\\.w\\.x|fcvt\\.l\\.s|fcvt\\.lu\\.s|fcvt\\.s\\.l|fcvt\\.s\\.lu)\\b", |
| 38 |
"name": "support.function.riscv.f" |
| 39 |
}, |
| 40 |
{ |
| 41 |
"comment": "D extension (double precision floating point)", |
| 42 |
"match": "\\b(fld|fsd|fmadd\\.d|fmsub\\.d|fnmsub\\.d|fnmadd\\.d|fadd\\.d|fsub\\.d|fmul\\.d|fdiv\\.d|fsqrt\\.d|fsgnj\\.d|fsgnjn\\.d|fsgnjx\\.d|fmin\\.d|fmax\\.d|fcvt\\.s\\.d|fcvt\\.d\\.s|feq\\.d|flt\\.d|fle\\.d|fclass\\.d|fcvt\\.w\\.d|fcvt\\.wu\\.d|fcvt\\.d\\.w|fcvt\\.d\\.wu|fcvt\\.l\\.d|fcvt\\.lu\\.d|fmv\\.x\\.d|fcvt\\.d\\.l|fcvt\\.d\\.lu|fmv\\.d\\.x)\\b", |
| 43 |
"name": "support.function.riscv.d" |
| 44 |
}, |
| 45 |
{ |
| 46 |
"match": "\\.(skip|ascii|asciiz|byte|[2|4|8]byte|data|double|float|half|kdata|ktext|space|text|word|dword|dtprelword|dtpreldword|set\\s*(noat|at)|[s|u]leb128|string|incbin|zero|rodata|comm|common)\\b", |
| 47 |
"name": "storage.type.riscv" |
| 48 |
}, |
| 49 |
{ |
| 50 |
"match": "\\.(balign|align|p2align|extern|globl|global|local|pushsection|section|bss|insn|option|type|equ|macro|endm|file|ident)\\b", |
| 51 |
"name": "storage.modifier.riscv" |
| 52 |
}, |
| 53 |
{ |
| 54 |
"captures": { |
| 55 |
"1": { |
| 56 |
"name": "entity.name.function.label.riscv" |
| 57 |
} |
| 58 |
}, |
| 59 |
"match": "\\b([A-Za-z0-9_]+):", |
| 60 |
"name": "meta.function.label.riscv" |
| 61 |
}, |
| 62 |
{ |
| 63 |
"captures": { |
| 64 |
"1": { |
| 65 |
"name": "punctuation.definition.variable.riscv" |
| 66 |
} |
| 67 |
}, |
| 68 |
"match": "\\b(x([0-9]|1[0-9]|2[0-9]|3[0-1]))\\b", |
| 69 |
"name": "variable.other.register.usable.by-number.riscv" |
| 70 |
}, |
| 71 |
{ |
| 72 |
"captures": { |
| 73 |
"1": { |
| 74 |
"name": "punctuation.definition.variable.riscv" |
| 75 |
} |
| 76 |
}, |
| 77 |
"match": "\\b(zero|ra|sp|gp|tp|t[0-6]|a[0-7]|s[0-9]|fp|s1[0-1])\\b", |
| 78 |
"name": "variable.other.register.usable.by-name.riscv" |
| 79 |
}, |
| 80 |
{ |
| 81 |
"captures": { |
| 82 |
"1": { |
| 83 |
"name": "punctuation.definition.variable.riscv" |
| 84 |
} |
| 85 |
}, |
| 86 |
"match": "\\b(([umsh]|vs)status|([umsh]|vs)ie|([ums]|vs)tvec|([ums]|vs)scratch|([ums]|vs)epc|([ums]|vs)cause|([umsh]|vs)tval|([umsh]|vs)ip|fflags|frm|fcsr|m?cycleh?|timeh?|m?instreth?|m?hpmcounter([3-9]|[12][0-9]|3[01])h?|[msh][ei]deleg|[msh]counteren|v?satp|hgeie|hgeip|[hm]tinst|hvip|hgatp|htimedeltah?|mvendorid|marchid|mimpid|mhartid|misa|mstatush|mtval2|pmpcfg[0-3]|pmpaddr([0-9]|1[0-5])|mcountinhibit|mhpmevent([3-9]|[12][0-9]|3[01])|tselect|tdata[1-3]|dcsr|dpc|dscratch[0-1])\\b", |
| 87 |
"name": "variable.other.csr.names.riscv" |
| 88 |
}, |
| 89 |
{ |
| 90 |
"captures": { |
| 91 |
"1": { |
| 92 |
"name": "punctuation.definition.variable.riscv" |
| 93 |
} |
| 94 |
}, |
| 95 |
"match": "\\bf([0-9]|1[0-9]|2[0-9]|3[0-1])\\b", |
| 96 |
"name": "variable.other.register.usable.floating-point.riscv" |
| 97 |
}, |
| 98 |
{ |
| 99 |
"match": "\\b\\d+\\.\\d+\\b", |
| 100 |
"name": "constant.numeric.float.riscv" |
| 101 |
}, |
| 102 |
{ |
| 103 |
"match": "\\b(\\d+|0(x|X)[a-fA-F0-9]+)\\b", |
| 104 |
"name": "constant.numeric.integer.riscv" |
| 105 |
}, |
| 106 |
{ |
| 107 |
"begin": "\"", |
| 108 |
"beginCaptures": { |
| 109 |
"0": { |
| 110 |
"name": "punctuation.definition.string.begin.riscv" |
| 111 |
} |
| 112 |
}, |
| 113 |
"end": "\"", |
| 114 |
"endCaptures": { |
| 115 |
"0": { |
| 116 |
"name": "punctuation.definition.string.end.riscv" |
| 117 |
} |
| 118 |
}, |
| 119 |
"name": "string.quoted.double.riscv", |
| 120 |
"patterns": [ |
| 121 |
{ |
| 122 |
"match": "\\\\[rnt\\\\\"]", |
| 123 |
"name": "constant.character.escape.riscv" |
| 124 |
} |
| 125 |
] |
| 126 |
}, |
| 127 |
{ |
| 128 |
"begin": "'", |
| 129 |
"beginCaptures": { |
| 130 |
"0": { |
| 131 |
"name": "punctuation.definition.string.begin.riscv" |
| 132 |
} |
| 133 |
}, |
| 134 |
"end": "'", |
| 135 |
"endCaptures": { |
| 136 |
"0": { |
| 137 |
"name": "punctuation.definition.string.end.riscv" |
| 138 |
} |
| 139 |
}, |
| 140 |
"name": "string.quoted.single.riscv", |
| 141 |
"patterns": [ |
| 142 |
{ |
| 143 |
"match": "\\\\[rnt\\\\\"]", |
| 144 |
"name": "constant.character.escape.riscv" |
| 145 |
} |
| 146 |
] |
| 147 |
}, |
| 148 |
{ |
| 149 |
"begin": "\\/\\*", |
| 150 |
"end": "\\*\\/", |
| 151 |
"name": "comment.block" |
| 152 |
}, |
| 153 |
{ |
| 154 |
"begin": "\\/\\/", |
| 155 |
"end": "\\n", |
| 156 |
"name": "comment.line.double-slash" |
| 157 |
}, |
| 158 |
{ |
| 159 |
"begin": "(?x)\n ^\\s*\\#\\s*(define)\\s+ # define\n ((?<id>[a-zA-Z_][a-zA-Z0-9_]*)) # macro name\n (?: # and optionally:\n (\\() # an open parenthesis\n (\n \\s* \\g<id> \\s* # first argument\n ((,) \\s* \\g<id> \\s*)* # additional arguments\n (?:\\.\\.\\.)? # varargs ellipsis?\n )\n (\\)) # a close parenthesis\n )?\n ", |
| 160 |
"beginCaptures": { |
| 161 |
"1": { |
| 162 |
"name": "keyword.control.import.define.c" |
| 163 |
}, |
| 164 |
"2": { |
| 165 |
"name": "entity.name.function.preprocessor.c" |
| 166 |
}, |
| 167 |
"4": { |
| 168 |
"name": "punctuation.definition.parameters.c" |
| 169 |
}, |
| 170 |
"5": { |
| 171 |
"name": "variable.parameter.preprocessor.c" |
| 172 |
}, |
| 173 |
"7": { |
| 174 |
"name": "punctuation.separator.parameters.c" |
| 175 |
}, |
| 176 |
"8": { |
| 177 |
"name": "punctuation.definition.parameters.c" |
| 178 |
} |
| 179 |
}, |
| 180 |
"end": "(?=(?://|/\\*))|$", |
| 181 |
"name": "meta.preprocessor.macro.c", |
| 182 |
"patterns": [ |
| 183 |
{ |
| 184 |
"match": "(?>\\\\\\s*\\n)", |
| 185 |
"name": "punctuation.separator.continuation.c" |
| 186 |
}, |
| 187 |
{ |
| 188 |
"include": "$base" |
| 189 |
} |
| 190 |
] |
| 191 |
}, |
| 192 |
{ |
| 193 |
"begin": "^\\s*#\\s*(error|warning)\\b", |
| 194 |
"captures": { |
| 195 |
"1": { |
| 196 |
"name": "keyword.control.import.error.c" |
| 197 |
} |
| 198 |
}, |
| 199 |
"end": "$", |
| 200 |
"name": "meta.preprocessor.diagnostic.c", |
| 201 |
"patterns": [ |
| 202 |
{ |
| 203 |
"match": "(?>\\\\\\s*\\n)", |
| 204 |
"name": "punctuation.separator.continuation.c" |
| 205 |
} |
| 206 |
] |
| 207 |
}, |
| 208 |
{ |
| 209 |
"begin": "^\\s*#\\s*(include|import)\\b\\s+", |
| 210 |
"captures": { |
| 211 |
"1": { |
| 212 |
"name": "keyword.control.import.include.c" |
| 213 |
} |
| 214 |
}, |
| 215 |
"end": "(?=(?://|/\\*))|$", |
| 216 |
"name": "meta.preprocessor.c.include", |
| 217 |
"patterns": [ |
| 218 |
{ |
| 219 |
"match": "(?>\\\\\\s*\\n)", |
| 220 |
"name": "punctuation.separator.continuation.c" |
| 221 |
}, |
| 222 |
{ |
| 223 |
"begin": "\"", |
| 224 |
"beginCaptures": { |
| 225 |
"0": { |
| 226 |
"name": "punctuation.definition.string.begin.c" |
| 227 |
} |
| 228 |
}, |
| 229 |
"end": "\"", |
| 230 |
"endCaptures": { |
| 231 |
"0": { |
| 232 |
"name": "punctuation.definition.string.end.c" |
| 233 |
} |
| 234 |
}, |
| 235 |
"name": "string.quoted.double.include.c" |
| 236 |
}, |
| 237 |
{ |
| 238 |
"begin": "<", |
| 239 |
"beginCaptures": { |
| 240 |
"0": { |
| 241 |
"name": "punctuation.definition.string.begin.c" |
| 242 |
} |
| 243 |
}, |
| 244 |
"end": ">", |
| 245 |
"endCaptures": { |
| 246 |
"0": { |
| 247 |
"name": "punctuation.definition.string.end.c" |
| 248 |
} |
| 249 |
}, |
| 250 |
"name": "string.quoted.other.lt-gt.include.c" |
| 251 |
} |
| 252 |
] |
| 253 |
}, |
| 254 |
{ |
| 255 |
"begin": "^\\s*#\\s*(define|defined|elif|else|if|ifdef|ifndef|line|pragma|undef|endif)\\b", |
| 256 |
"captures": { |
| 257 |
"1": { |
| 258 |
"name": "keyword.control.import.c" |
| 259 |
} |
| 260 |
}, |
| 261 |
"end": "(?=(?://|/\\*))|$", |
| 262 |
"name": "meta.preprocessor.c", |
| 263 |
"patterns": [ |
| 264 |
{ |
| 265 |
"match": "(?>\\\\\\s*\\n)", |
| 266 |
"name": "punctuation.separator.continuation.c" |
| 267 |
} |
| 268 |
] |
| 269 |
}, |
| 270 |
{ |
| 271 |
"begin": "(^[ \\t]+)?(?=#)", |
| 272 |
"beginCaptures": { |
| 273 |
"1": { |
| 274 |
"name": "punctuation.whitespace.comment.leading.riscv" |
| 275 |
} |
| 276 |
}, |
| 277 |
"end": "(?!\\G)", |
| 278 |
"patterns": [ |
| 279 |
{ |
| 280 |
"begin": "#|(\\/\\/)", |
| 281 |
"beginCaptures": { |
| 282 |
"0": { |
| 283 |
"name": "punctuation.definition.comment.riscv" |
| 284 |
} |
| 285 |
}, |
| 286 |
"end": "\\n", |
| 287 |
"name": "comment.line.number-sign.riscv" |
| 288 |
} |
| 289 |
] |
| 290 |
} |
| 291 |
], |
| 292 |
"scopeName": "source.riscv", |
| 293 |
"uuid": "003223C7-B8D1-4B7F-BF91-5E0062B19B53" |
| 294 |
} |
| 295 |
|