10b57cec5SDimitry Andric//WebAssemblyRegisterInfo.td-Describe the WebAssembly Registers -*- tablegen -*- 20b57cec5SDimitry Andric// 30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric// 70b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric/// 90b57cec5SDimitry Andric/// \file 100b57cec5SDimitry Andric/// This file describes the WebAssembly register classes and some nominal 110b57cec5SDimitry Andric/// physical registers. 120b57cec5SDimitry Andric/// 130b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 140b57cec5SDimitry Andric 150b57cec5SDimitry Andricclass WebAssemblyReg<string n> : Register<n> { 160b57cec5SDimitry Andric let Namespace = "WebAssembly"; 170b57cec5SDimitry Andric} 180b57cec5SDimitry Andric 190b57cec5SDimitry Andricclass WebAssemblyRegClass<list<ValueType> regTypes, int alignment, dag regList> 200b57cec5SDimitry Andric : RegisterClass<"WebAssembly", regTypes, alignment, regList>; 210b57cec5SDimitry Andric 220b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 230b57cec5SDimitry Andric// Registers 240b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 250b57cec5SDimitry Andric 260b57cec5SDimitry Andric// Special registers used as the frame and stack pointer. 270b57cec5SDimitry Andric// 280b57cec5SDimitry Andric// WebAssembly may someday supports mixed 32-bit and 64-bit heaps in the same 290b57cec5SDimitry Andric// application, which requires separate width FP and SP. 300b57cec5SDimitry Andricdef FP32 : WebAssemblyReg<"%FP32">; 310b57cec5SDimitry Andricdef FP64 : WebAssemblyReg<"%FP64">; 320b57cec5SDimitry Andricdef SP32 : WebAssemblyReg<"%SP32">; 330b57cec5SDimitry Andricdef SP64 : WebAssemblyReg<"%SP64">; 340b57cec5SDimitry Andric 350b57cec5SDimitry Andric// The register allocation framework requires register classes have at least 360b57cec5SDimitry Andric// one register, so we define a few for the integer / floating point register 370b57cec5SDimitry Andric// classes since we otherwise don't need a physical register in those classes. 380b57cec5SDimitry Andric// These are also used a "types" in the generated assembly matcher. 390b57cec5SDimitry Andricdef I32_0 : WebAssemblyReg<"%i32.0">; 400b57cec5SDimitry Andricdef I64_0 : WebAssemblyReg<"%i64.0">; 410b57cec5SDimitry Andricdef F32_0 : WebAssemblyReg<"%f32.0">; 420b57cec5SDimitry Andricdef F64_0 : WebAssemblyReg<"%f64.0">; 430b57cec5SDimitry Andric 440b57cec5SDimitry Andricdef V128_0: WebAssemblyReg<"%v128">; 450b57cec5SDimitry Andric 46e8d8bef9SDimitry Andricdef FUNCREF_0 : WebAssemblyReg<"%funcref.0">; 47e8d8bef9SDimitry Andricdef EXTERNREF_0 : WebAssemblyReg<"%externref.0">; 48*0fca6ea1SDimitry Andricdef EXNREF_0 : WebAssemblyReg<"%exnref.0">; 490b57cec5SDimitry Andric 500b57cec5SDimitry Andric// The value stack "register". This is an opaque entity which serves to order 510b57cec5SDimitry Andric// uses and defs that must remain in LIFO order. 520b57cec5SDimitry Andricdef VALUE_STACK : WebAssemblyReg<"STACK">; 530b57cec5SDimitry Andric 540b57cec5SDimitry Andric// The incoming arguments "register". This is an opaque entity which serves to 550b57cec5SDimitry Andric// order the ARGUMENT instructions that are emulating live-in registers and 560b57cec5SDimitry Andric// must not be scheduled below other instructions. 570b57cec5SDimitry Andricdef ARGUMENTS : WebAssemblyReg<"ARGUMENTS">; 580b57cec5SDimitry Andric 590b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 600b57cec5SDimitry Andric// Register classes 610b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 620b57cec5SDimitry Andric 630b57cec5SDimitry Andricdef I32 : WebAssemblyRegClass<[i32], 32, (add FP32, SP32, I32_0)>; 640b57cec5SDimitry Andricdef I64 : WebAssemblyRegClass<[i64], 64, (add FP64, SP64, I64_0)>; 650b57cec5SDimitry Andricdef F32 : WebAssemblyRegClass<[f32], 32, (add F32_0)>; 660b57cec5SDimitry Andricdef F64 : WebAssemblyRegClass<[f64], 64, (add F64_0)>; 67*0fca6ea1SDimitry Andricdef V128 : WebAssemblyRegClass<[v8f16, v4f32, v2f64, v2i64, v4i32, v16i8, 68*0fca6ea1SDimitry Andric v8i16], 69*0fca6ea1SDimitry Andric 128, (add V128_0)>; 70e8d8bef9SDimitry Andricdef FUNCREF : WebAssemblyRegClass<[funcref], 0, (add FUNCREF_0)>; 71e8d8bef9SDimitry Andricdef EXTERNREF : WebAssemblyRegClass<[externref], 0, (add EXTERNREF_0)>; 72*0fca6ea1SDimitry Andricdef EXNREF : WebAssemblyRegClass<[exnref], 0, (add EXNREF_0)>; 73