Skip to content

Commit

Permalink
Adding check to see if size is > 8x8bytes, in which case goes to MEMO…
Browse files Browse the repository at this point in the history
…RY (#78)

* adding check to see if size is > 8x8bytes, in which case goes to MEMORY
* keep scaled to bytes

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Co-authored-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch and vsoch committed Aug 27, 2021
1 parent 88754c6 commit bf431bd
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions source/parser/x86_64/classifiers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,28 @@ namespace smeagle::x86_64 {
return {RegisterClass::NO_CLASS, RegisterClass::NO_CLASS, "Unknown"};
}

inline classification classify(st::typeStruct *) {
inline classification classify(st::typeStruct *t) {
const auto size = t->getSize();

// If an object is larger than eight eightbyes (i.e., 64) class MEMORY.
if (size > 64) {
return {RegisterClass::MEMORY, RegisterClass::NO_CLASS, "Struct"};
}

return {RegisterClass::INTEGER, RegisterClass::NO_CLASS, "Struct"};
}
inline classification classify(st::typeUnion *) {
inline classification classify(st::typeUnion *t) {
const auto size = t->getSize();
if (size > 64) {
return {RegisterClass::MEMORY, RegisterClass::NO_CLASS, "Union"};
}
return {RegisterClass::INTEGER, RegisterClass::NO_CLASS, "Union"};
}
inline classification classify(st::typeArray *) {
inline classification classify(st::typeArray *t) {
const auto size = t->getSize();
if (size > 64) {
return {RegisterClass::MEMORY, RegisterClass::NO_CLASS, "Array"};
}
return {RegisterClass::INTEGER, RegisterClass::NO_CLASS, "Array"};
}
inline classification classify(st::typeEnum *) {
Expand Down

0 comments on commit bf431bd

Please sign in to comment.