Implement SystemV struct argument passing
This commit is contained in:
@@ -329,6 +329,7 @@ impl<'a> Lexer<'a> {
|
||||
.unwrap_or_else(|| match text {
|
||||
"iflags" => Token::Type(types::IFLAGS),
|
||||
"fflags" => Token::Type(types::FFLAGS),
|
||||
"sarg__" => Token::Type(types::SARG__),
|
||||
_ => Token::Identifier(text),
|
||||
}),
|
||||
loc,
|
||||
@@ -620,7 +621,7 @@ mod tests {
|
||||
let mut lex = Lexer::new(
|
||||
"v0 v00 vx01 block1234567890 block5234567890 v1x vx1 vxvx4 \
|
||||
function0 function b1 i32x4 f32x5 \
|
||||
iflags fflags iflagss",
|
||||
iflags fflags sarg__ iflagss",
|
||||
);
|
||||
assert_eq!(
|
||||
lex.next(),
|
||||
@@ -643,6 +644,7 @@ mod tests {
|
||||
assert_eq!(lex.next(), token(Token::Identifier("f32x5"), 1));
|
||||
assert_eq!(lex.next(), token(Token::Type(types::IFLAGS), 1));
|
||||
assert_eq!(lex.next(), token(Token::Type(types::FFLAGS), 1));
|
||||
assert_eq!(lex.next(), token(Token::Type(types::SARG__), 1));
|
||||
assert_eq!(lex.next(), token(Token::Identifier("iflagss"), 1));
|
||||
assert_eq!(lex.next(), None);
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ use cranelift_codegen::ir::instructions::{InstructionData, InstructionFormat, Va
|
||||
use cranelift_codegen::ir::types::INVALID;
|
||||
use cranelift_codegen::ir::types::*;
|
||||
use cranelift_codegen::ir::{
|
||||
AbiParam, ArgumentExtension, ArgumentLoc, Block, Constant, ConstantData, ExtFuncData,
|
||||
ExternalName, FuncRef, Function, GlobalValue, GlobalValueData, Heap, HeapData, HeapStyle,
|
||||
JumpTable, JumpTableData, MemFlags, Opcode, SigRef, Signature, StackSlot, StackSlotData,
|
||||
StackSlotKind, Table, TableData, Type, Value, ValueLoc,
|
||||
AbiParam, ArgumentExtension, ArgumentLoc, ArgumentPurpose, Block, Constant, ConstantData,
|
||||
ExtFuncData, ExternalName, FuncRef, Function, GlobalValue, GlobalValueData, Heap, HeapData,
|
||||
HeapStyle, JumpTable, JumpTableData, MemFlags, Opcode, SigRef, Signature, StackSlot,
|
||||
StackSlotData, StackSlotKind, Table, TableData, Type, Value, ValueLoc,
|
||||
};
|
||||
use cranelift_codegen::isa::{self, CallConv, Encoding, RegUnit, TargetIsa};
|
||||
use cranelift_codegen::packed_option::ReservedValue;
|
||||
@@ -1423,6 +1423,14 @@ impl<'a> Parser<'a> {
|
||||
match s {
|
||||
"uext" => arg.extension = ArgumentExtension::Uext,
|
||||
"sext" => arg.extension = ArgumentExtension::Sext,
|
||||
"sarg" => {
|
||||
self.consume();
|
||||
self.match_token(Token::LPar, "expected '(' to begin sarg size")?;
|
||||
let size = self.match_uimm32("expected byte-size in sarg decl")?;
|
||||
self.match_token(Token::RPar, "expected ')' to end sarg size")?;
|
||||
arg.purpose = ArgumentPurpose::StructArgument(size.into());
|
||||
continue;
|
||||
}
|
||||
_ => {
|
||||
if let Ok(purpose) = s.parse() {
|
||||
arg.purpose = purpose;
|
||||
|
||||
Reference in New Issue
Block a user