Ygen/Target/x64/
mod.rs

1//! The x64 Target: used for compiling ir and inline asm into x64 machine code
2
3use std::collections::VecDeque;
4
5mod compilation;
6//use compilation::*;
7
8use super::{CallConv, Lexer, TargetBackendDescr, WhiteList};
9mod reg;
10use compilation::construct_compilation_helper;
11pub use reg::*;
12
13pub(crate) mod call;
14mod asm;
15mod lower;
16
17pub use asm::*;
18
19use crate::{CodeGen::MachineMnemonic, Target::Compiler};
20
21/// Initializes the x86-64 target
22pub fn initializeX64Target(call_conv: CallConv) -> TargetBackendDescr {
23    let mut target = TargetBackendDescr::new();
24
25    target.call = call_conv;
26
27    target.init = Some(initializeX64Target);
28
29    target.lexer = Some(x64Lexer {}.boxed());
30    target.compile = Some(x64Parser { tokens: VecDeque::new(), out: None }.boxed());
31
32    target.whitelist = construct_whitelist();
33
34    target.helper = Some(construct_compilation_helper(call_conv));
35
36    target
37}
38
39fn construct_whitelist() -> WhiteList {
40    let mut whitelist = WhiteList::new();
41
42    // everything is allowed by default
43    // so only add illegal stuff here
44
45    whitelist.forbid(MachineMnemonic::Div);
46    whitelist.forbid(MachineMnemonic::Downcast);
47
48    whitelist
49}