1b8021494Sopenharmony_ci// Copyright 2016, VIXL authors 2b8021494Sopenharmony_ci// All rights reserved. 3b8021494Sopenharmony_ci// 4b8021494Sopenharmony_ci// Redistribution and use in source and binary forms, with or without 5b8021494Sopenharmony_ci// modification, are permitted provided that the following conditions are met: 6b8021494Sopenharmony_ci// 7b8021494Sopenharmony_ci// * Redistributions of source code must retain the above copyright notice, 8b8021494Sopenharmony_ci// this list of conditions and the following disclaimer. 9b8021494Sopenharmony_ci// * Redistributions in binary form must reproduce the above copyright notice, 10b8021494Sopenharmony_ci// this list of conditions and the following disclaimer in the documentation 11b8021494Sopenharmony_ci// and/or other materials provided with the distribution. 12b8021494Sopenharmony_ci// * Neither the name of ARM Limited nor the names of its contributors may be 13b8021494Sopenharmony_ci// used to endorse or promote products derived from this software without 14b8021494Sopenharmony_ci// specific prior written permission. 15b8021494Sopenharmony_ci// 16b8021494Sopenharmony_ci// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND 17b8021494Sopenharmony_ci// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18b8021494Sopenharmony_ci// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19b8021494Sopenharmony_ci// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20b8021494Sopenharmony_ci// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21b8021494Sopenharmony_ci// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22b8021494Sopenharmony_ci// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23b8021494Sopenharmony_ci// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24b8021494Sopenharmony_ci// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25b8021494Sopenharmony_ci// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26b8021494Sopenharmony_ci 27b8021494Sopenharmony_ci#ifndef VIXL_MACRO_ASSEMBLER_INTERFACE_H 28b8021494Sopenharmony_ci#define VIXL_MACRO_ASSEMBLER_INTERFACE_H 29b8021494Sopenharmony_ci 30b8021494Sopenharmony_ci#include "assembler-base-vixl.h" 31b8021494Sopenharmony_ci 32b8021494Sopenharmony_cinamespace vixl { 33b8021494Sopenharmony_ci 34b8021494Sopenharmony_ciclass MacroAssemblerInterface { 35b8021494Sopenharmony_ci public: 36b8021494Sopenharmony_ci virtual internal::AssemblerBase* AsAssemblerBase() = 0; 37b8021494Sopenharmony_ci 38b8021494Sopenharmony_ci virtual ~MacroAssemblerInterface() VIXL_NEGATIVE_TESTING_ALLOW_EXCEPTION {} 39b8021494Sopenharmony_ci 40b8021494Sopenharmony_ci virtual bool AllowMacroInstructions() const = 0; 41b8021494Sopenharmony_ci virtual bool ArePoolsBlocked() const = 0; 42b8021494Sopenharmony_ci 43b8021494Sopenharmony_ci protected: 44b8021494Sopenharmony_ci virtual void SetAllowMacroInstructions(bool allow) = 0; 45b8021494Sopenharmony_ci 46b8021494Sopenharmony_ci virtual void BlockPools() = 0; 47b8021494Sopenharmony_ci virtual void ReleasePools() = 0; 48b8021494Sopenharmony_ci virtual void EnsureEmitPoolsFor(size_t size) = 0; 49b8021494Sopenharmony_ci 50b8021494Sopenharmony_ci // Emit the branch over a literal/veneer pool, and any necessary padding 51b8021494Sopenharmony_ci // before it. 52b8021494Sopenharmony_ci virtual void EmitPoolHeader() = 0; 53b8021494Sopenharmony_ci // When this is called, the label used for branching over the pool is bound. 54b8021494Sopenharmony_ci // This can also generate additional padding, which must correspond to the 55b8021494Sopenharmony_ci // alignment_ value passed to the PoolManager (which needs to keep track of 56b8021494Sopenharmony_ci // the exact size of the generated pool). 57b8021494Sopenharmony_ci virtual void EmitPoolFooter() = 0; 58b8021494Sopenharmony_ci 59b8021494Sopenharmony_ci // Emit n bytes of padding that does not have to be executable. 60b8021494Sopenharmony_ci virtual void EmitPaddingBytes(int n) = 0; 61b8021494Sopenharmony_ci // Emit n bytes of padding that has to be executable. Implementations must 62b8021494Sopenharmony_ci // make sure this is a multiple of the instruction size. 63b8021494Sopenharmony_ci virtual void EmitNopBytes(int n) = 0; 64b8021494Sopenharmony_ci 65b8021494Sopenharmony_ci // The following scopes need access to the above method in order to implement 66b8021494Sopenharmony_ci // pool blocking and temporarily disable the macro-assembler. 67b8021494Sopenharmony_ci friend class ExactAssemblyScope; 68b8021494Sopenharmony_ci friend class EmissionCheckScope; 69b8021494Sopenharmony_ci template <typename T> 70b8021494Sopenharmony_ci friend class PoolManager; 71b8021494Sopenharmony_ci}; 72b8021494Sopenharmony_ci 73b8021494Sopenharmony_ci} // namespace vixl 74b8021494Sopenharmony_ci 75b8021494Sopenharmony_ci#endif // VIXL_MACRO_ASSEMBLER_INTERFACE_H 76