Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1470)

Unified Diff: test/cctest/test-assembler-arm.cc

Issue 1776933003: [arm] Basic simulation of msr and mrs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/arm/simulator-arm.cc ('k') | test/cctest/test-disasm-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-assembler-arm.cc
diff --git a/test/cctest/test-assembler-arm.cc b/test/cctest/test-assembler-arm.cc
index 68eaab16f6f55f2f0830027ecf2fc075914bd6ba..7d37bcdd2e3d8b7d75a4d55d18e79510a6071d8a 100644
--- a/test/cctest/test-assembler-arm.cc
+++ b/test/cctest/test-assembler-arm.cc
@@ -46,7 +46,7 @@ typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4);
typedef Object* (*F2)(int x, int y, int p2, int p3, int p4);
typedef Object* (*F3)(void* p0, int p1, int p2, int p3, int p4);
typedef Object* (*F4)(void* p0, void* p1, int p2, int p3, int p4);
-
+typedef Object* (*F5)(uint32_t p0, void* p1, void* p2, int p3, int p4);
#define __ assm.
@@ -1939,6 +1939,78 @@ TEST(code_relative_offset) {
CHECK_EQ(42, res);
}
+TEST(msr_mrs) {
+ // Test msr and mrs.
+ CcTest::InitializeVM();
+ Isolate* isolate = CcTest::i_isolate();
+ HandleScope scope(isolate);
+
+ Assembler assm(isolate, NULL, 0);
+
+ // Create a helper function:
+ // void TestMsrMrs(uint32_t nzcv,
+ // uint32_t * result_conditionals,
+ // uint32_t * result_mrs);
+ __ msr(CPSR_f, Operand(r0));
+
+ // Test that the condition flags have taken effect.
+ __ mov(r3, Operand(0));
+ __ orr(r3, r3, Operand(1 << 31), LeaveCC, mi); // N
+ __ orr(r3, r3, Operand(1 << 30), LeaveCC, eq); // Z
+ __ orr(r3, r3, Operand(1 << 29), LeaveCC, cs); // C
+ __ orr(r3, r3, Operand(1 << 28), LeaveCC, vs); // V
+ __ str(r3, MemOperand(r1));
+
+ // Also check mrs, ignoring everything other than the flags.
+ __ mrs(r3, CPSR);
+ __ and_(r3, r3, Operand(kSpecialCondition));
+ __ str(r3, MemOperand(r2));
+
+ __ bx(lr);
+
+ CodeDesc desc;
+ assm.GetCode(&desc);
+ Handle<Code> code = isolate->factory()->NewCode(
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
+#ifdef DEBUG
+ OFStream os(stdout);
+ code->Print(os);
+#endif
+ F5 f = FUNCTION_CAST<F5>(code->entry());
+ Object* dummy = nullptr;
+ USE(dummy);
+
+#define CHECK_MSR_MRS(n, z, c, v) \
+ do { \
+ uint32_t nzcv = (n << 31) | (z << 30) | (c << 29) | (v << 28); \
+ uint32_t result_conditionals = -1; \
+ uint32_t result_mrs = -1; \
+ dummy = CALL_GENERATED_CODE(isolate, f, nzcv, &result_conditionals, \
+ &result_mrs, 0, 0); \
+ CHECK_EQ(nzcv, result_conditionals); \
+ CHECK_EQ(nzcv, result_mrs); \
+ } while (0);
+
+ // N Z C V
+ CHECK_MSR_MRS(0, 0, 0, 0);
+ CHECK_MSR_MRS(0, 0, 0, 1);
+ CHECK_MSR_MRS(0, 0, 1, 0);
+ CHECK_MSR_MRS(0, 0, 1, 1);
+ CHECK_MSR_MRS(0, 1, 0, 0);
+ CHECK_MSR_MRS(0, 1, 0, 1);
+ CHECK_MSR_MRS(0, 1, 1, 0);
+ CHECK_MSR_MRS(0, 1, 1, 1);
+ CHECK_MSR_MRS(1, 0, 0, 0);
+ CHECK_MSR_MRS(1, 0, 0, 1);
+ CHECK_MSR_MRS(1, 0, 1, 0);
+ CHECK_MSR_MRS(1, 0, 1, 1);
+ CHECK_MSR_MRS(1, 1, 0, 0);
+ CHECK_MSR_MRS(1, 1, 0, 1);
+ CHECK_MSR_MRS(1, 1, 1, 0);
+ CHECK_MSR_MRS(1, 1, 1, 1);
+
+#undef CHECK_MSR_MRS
+}
TEST(ARMv8_float32_vrintX) {
// Test the vrintX floating point instructions.
« no previous file with comments | « src/arm/simulator-arm.cc ('k') | test/cctest/test-disasm-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698