mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 23:23:38 -04:00
[WebAssembly] v128.const
Summary: This CL implements v128.const for each vector type. New operand types are added to ensure the vector contents can be serialized without LEB encoding. Tests are added for instruction selection, encoding, assembly and disassembly. Reviewers: aheejin, dschuff, aardappel Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D50873 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340336 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -92,14 +92,18 @@ static bool parseLEBImmediate(MCInst &MI, uint64_t &Size,
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool parseFPImmediate(MCInst &MI, uint64_t &Size, ArrayRef<uint8_t> Bytes) {
|
||||
bool parseImmediate(MCInst &MI, uint64_t &Size, ArrayRef<uint8_t> Bytes) {
|
||||
if (Size + sizeof(T) > Bytes.size())
|
||||
return false;
|
||||
T Val;
|
||||
memcpy(&Val, Bytes.data() + Size, sizeof(T));
|
||||
support::endian::byte_swap<T, support::endianness::little>(Val);
|
||||
Size += sizeof(T);
|
||||
MI.addOperand(MCOperand::createFPImm(static_cast<double>(Val)));
|
||||
if (std::is_floating_point<T>::value) {
|
||||
MI.addOperand(MCOperand::createFPImm(static_cast<double>(Val)));
|
||||
} else {
|
||||
MI.addOperand(MCOperand::createImm(static_cast<int64_t>(Val)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -160,12 +164,33 @@ MCDisassembler::DecodeStatus WebAssemblyDisassembler::getInstruction(
|
||||
}
|
||||
// FP operands.
|
||||
case WebAssembly::OPERAND_F32IMM: {
|
||||
if (!parseFPImmediate<float>(MI, Size, Bytes))
|
||||
if (!parseImmediate<float>(MI, Size, Bytes))
|
||||
return MCDisassembler::Fail;
|
||||
break;
|
||||
}
|
||||
case WebAssembly::OPERAND_F64IMM: {
|
||||
if (!parseFPImmediate<double>(MI, Size, Bytes))
|
||||
if (!parseImmediate<double>(MI, Size, Bytes))
|
||||
return MCDisassembler::Fail;
|
||||
break;
|
||||
}
|
||||
// Vector lane operands (not LEB encoded).
|
||||
case WebAssembly::OPERAND_VEC_I8IMM: {
|
||||
if (!parseImmediate<uint8_t>(MI, Size, Bytes))
|
||||
return MCDisassembler::Fail;
|
||||
break;
|
||||
}
|
||||
case WebAssembly::OPERAND_VEC_I16IMM: {
|
||||
if (!parseImmediate<uint16_t>(MI, Size, Bytes))
|
||||
return MCDisassembler::Fail;
|
||||
break;
|
||||
}
|
||||
case WebAssembly::OPERAND_VEC_I32IMM: {
|
||||
if (!parseImmediate<uint32_t>(MI, Size, Bytes))
|
||||
return MCDisassembler::Fail;
|
||||
break;
|
||||
}
|
||||
case WebAssembly::OPERAND_VEC_I64IMM: {
|
||||
if (!parseImmediate<uint64_t>(MI, Size, Bytes))
|
||||
return MCDisassembler::Fail;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user