#include "llvm/Support/TypeSize.h"
#include "AArch64InstrInfo.h"
#include "gtest/gtest.h"
using namespace llvm;
TEST(StackOffset, decomposeStackOffsetForFrameOffsets) {
StackOffset A = StackOffset::getFixed(8);
StackOffset B = StackOffset::getFixed(4);
StackOffset C = StackOffset::getScalable(16);
int64_t ByteSized, VLSized, PLSized;
AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(A + B + C, ByteSized, PLSized,
VLSized);
EXPECT_EQ(12, ByteSized);
EXPECT_EQ(1, VLSized);
EXPECT_EQ(0, PLSized);
StackOffset D = StackOffset::getScalable(2);
AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(C + D, ByteSized, PLSized, VLSized);
EXPECT_EQ(0, ByteSized);
EXPECT_EQ(0, VLSized);
EXPECT_EQ(9, PLSized);
StackOffset E = StackOffset::getScalable(64);
StackOffset F = StackOffset::getScalable(2);
AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(E + F, ByteSized, PLSized, VLSized);
EXPECT_EQ(0, ByteSized);
EXPECT_EQ(0, VLSized);
EXPECT_EQ(33, PLSized);
StackOffset G = StackOffset::getScalable(128);
StackOffset H = StackOffset::getScalable(2);
AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(G + H, ByteSized, PLSized, VLSized);
EXPECT_EQ(0, ByteSized);
EXPECT_EQ(8, VLSized);
EXPECT_EQ(1, PLSized);
}