diff options
author | Alexandre Rames <alexandre.rames@linaro.org> | 2016-11-22 16:35:55 +0000 |
---|---|---|
committer | Alexandre Rames <alexandre.rames@linaro.org> | 2016-11-23 15:14:22 +0000 |
commit | a38f9aec7b79989b658790b2492e2de67a64b430 (patch) | |
tree | c396e4cb84de634c2539ada534308d264e0f3a13 /test/aarch64 | |
parent | fad927c4321a9dd7e235b91aadd88f5542561370 (diff) | |
download | vixl-a38f9aec7b79989b658790b2492e2de67a64b430.tar.gz |
Ensure `MacroAssembler::Nop` generates a single `nop`.
The `MacroAssembler` is allowed to emit any code that is functionally
equivalent to what is requested by the user, and is expected to
generate 'good' code. The user can expect calls such as
`masm.Add(r0, r0, 0)` to be optimized away (think that `0` may be the
value of a variable).
Following this we *could* generate no code for calls to `Nop()`. But
`Nop()` will likely not be used by mistake, so we ensure it generates
at least one `nop` instruction. This is useful for tests where we want
to generate 'some' code.
Change-Id: Iecf31b5cfd151a77b1633ea5158ff54fef9f8908
Diffstat (limited to 'test/aarch64')
-rw-r--r-- | test/aarch64/test-assembler-aarch64.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/test/aarch64/test-assembler-aarch64.cc b/test/aarch64/test-assembler-aarch64.cc index c4594e9c..f0720f3c 100644 --- a/test/aarch64/test-assembler-aarch64.cc +++ b/test/aarch64/test-assembler-aarch64.cc @@ -22596,11 +22596,11 @@ TEST(optimised_mov_register) { Label start; __ Bind(&start); __ Mov(x0, x0); - VIXL_CHECK(__ GetSizeOfCodeGeneratedSince(&start) == 0); + VIXL_CHECK(masm.GetSizeOfCodeGeneratedSince(&start) == 0); __ Mov(w0, w0, kDiscardForSameWReg); - VIXL_CHECK(__ GetSizeOfCodeGeneratedSince(&start) == 0); + VIXL_CHECK(masm.GetSizeOfCodeGeneratedSince(&start) == 0); __ Mov(w0, w0); - VIXL_CHECK(__ GetSizeOfCodeGeneratedSince(&start) == kInstructionSize); + VIXL_CHECK(masm.GetSizeOfCodeGeneratedSince(&start) == kInstructionSize); END(); @@ -22610,5 +22610,18 @@ TEST(optimised_mov_register) { } +TEST(nop) { + MacroAssembler masm; + + Label start; + __ Bind(&start); + __ Nop(); + // `MacroAssembler::Nop` must generate at least one nop. + VIXL_CHECK(masm.GetSizeOfCodeGeneratedSince(&start) >= kInstructionSize); + + masm.FinalizeCode(); +} + + } // namespace aarch64 } // namespace vixl |