// Generic assembly language definitions
// Copyright (C) Florian Negele

// This file is part of the Eigen Compiler Suite.

// The ECS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// The ECS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of the GNU General Public License version 3,
// the copyright holder grants you additional permissions to use
// this file as described in the ECS Runtime Support Exception.

// You should have received a copy of the GNU General Public License
// and a copy of the ECS Runtime Support Exception along with
// the ECS.  If not, see <https://www.gnu.org/licenses/>.

#ifndef ECS_DEF_ASSEMBLY_HEADER_INCLUDED
#define ECS_DEF_ASSEMBLY_HEADER_INCLUDED

#define LINE(...) #__VA_ARGS__ "\n"
#define DIRECTIVE(name, ...) name " " LINE (__VA_ARGS__)
#define INSTR(...) LINE (__VA_ARGS__)
#define LABEL(name) LINE (name:)

#define ALIAS(name) DIRECTIVE (".alias", name)
#define ALIGN(value) DIRECTIVE (".align", value)
#define ALIGNMENT(value) DIRECTIVE (".alignment", value)
#define ASSERT(value) DIRECTIVE (".assert", value)
#define BIG DIRECTIVE (".big")
#define BITMODE(value) DIRECTIVE (".bitmode", value)
#define BYTE(...) DIRECTIVE (".byte", __VA_ARGS__)
#define CODE(name) DIRECTIVE (".code", name)
#define CONST(name) DIRECTIVE (".const", name)
#define DATA(name) DIRECTIVE (".data", name)
#define DBYTE(...) DIRECTIVE (".dbyte", __VA_ARGS__)
#define DEFAULT DIRECTIVE (".default")
#define DEFINE(name) DIRECTIVE ("#define", name)
#define ELIF(value) DIRECTIVE ("#elif", value)
#define ELSE DIRECTIVE ("#else")
#define EMBED(file) DIRECTIVE (".embed", file)
#define END DIRECTIVE ("#end")
#define ENDDEF DIRECTIVE ("#enddef")
#define ENDIF DIRECTIVE ("#endif")
#define ENDREP DIRECTIVE ("#endrep")
#define EQUALS(name, value) #name ":" DIRECTIVE (".equals", value)
#define GROUP(name) DIRECTIVE (".group", name)
#define HEADER(name) DIRECTIVE (".header", name)
#define IF(value) DIRECTIVE ("#if", value)
#define INITCODE(name) DIRECTIVE (".initcode", name)
#define INITDATA(name) DIRECTIVE (".initdata", name)
#define LITTLE DIRECTIVE (".little")
#define OBYTE(...) DIRECTIVE (".obyte", __VA_ARGS__)
#define ORIGIN(value) DIRECTIVE (".origin", value)
#define PAD(value) DIRECTIVE (".pad", value)
#define PHANTOM DIRECTIVE (".phantom")
#define QBYTE(...) DIRECTIVE (".qbyte", __VA_ARGS__)
#define REPEAT(value) DIRECTIVE ("#repeat", value)
#define REQUIRE(name) DIRECTIVE (".require", name)
#define REQUIRED DIRECTIVE (".required")
#define RESERVE(value) DIRECTIVE (".reserve", value)
#define SHARED DIRECTIVE (".shared")
#define TBYTE(...) DIRECTIVE (".tbyte", __VA_ARGS__)
#define TRACE(...) DIRECTIVE (".trace", __VA_ARGS__)
#define TRAILER(name) DIRECTIVE (".trailer", name)
#define UNDEF(name) DIRECTIVE ("#undef", name)

#define TOKEN(prefix, suffix) prefix##suffix
#define __ TOKEN (#, #)
#define _0 TOKEN (#, 0)
#define _1 TOKEN (#, 1)
#define _2 TOKEN (#, 2)
#define _3 TOKEN (#, 3)
#define _4 TOKEN (#, 4)
#define _5 TOKEN (#, 5)
#define _6 TOKEN (#, 6)
#define _7 TOKEN (#, 7)
#define _8 TOKEN (#, 8)
#define _9 TOKEN (#, 9)

#endif // ECS_DEF_ASSEMBLY_HEADER_INCLUDED
