11cb0ef41Sopenharmony_ci// Copyright 2016 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#include "src/codegen/ppc/constants-ppc.h"
61cb0ef41Sopenharmony_ci#include "src/diagnostics/eh-frame.h"
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_cinamespace v8 {
91cb0ef41Sopenharmony_cinamespace internal {
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst int EhFrameConstants::kCodeAlignmentFactor = 4;
121cb0ef41Sopenharmony_ci// all PPC are 4 bytes instruction
131cb0ef41Sopenharmony_ciconst int EhFrameConstants::kDataAlignmentFactor = -8;  // 64-bit always -8
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_civoid EhFrameWriter::WriteReturnAddressRegisterCode() {
161cb0ef41Sopenharmony_ci  WriteULeb128(kLrDwarfCode);
171cb0ef41Sopenharmony_ci}
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_civoid EhFrameWriter::WriteInitialStateInCie() {
201cb0ef41Sopenharmony_ci  SetBaseAddressRegisterAndOffset(fp, 0);
211cb0ef41Sopenharmony_ci  RecordRegisterNotModified(kLrDwarfCode);
221cb0ef41Sopenharmony_ci}
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci// static
251cb0ef41Sopenharmony_ciint EhFrameWriter::RegisterToDwarfCode(Register name) {
261cb0ef41Sopenharmony_ci  switch (name.code()) {
271cb0ef41Sopenharmony_ci    case kRegCode_fp:
281cb0ef41Sopenharmony_ci      return kFpDwarfCode;
291cb0ef41Sopenharmony_ci    case kRegCode_sp:
301cb0ef41Sopenharmony_ci      return kSpDwarfCode;
311cb0ef41Sopenharmony_ci    case kRegCode_r0:
321cb0ef41Sopenharmony_ci      return kR0DwarfCode;
331cb0ef41Sopenharmony_ci    default:
341cb0ef41Sopenharmony_ci      UNIMPLEMENTED();
351cb0ef41Sopenharmony_ci  }
361cb0ef41Sopenharmony_ci}
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ci#ifdef ENABLE_DISASSEMBLER
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ci// static
411cb0ef41Sopenharmony_ciconst char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) {
421cb0ef41Sopenharmony_ci  switch (code) {
431cb0ef41Sopenharmony_ci    case kFpDwarfCode:
441cb0ef41Sopenharmony_ci      return "fp";
451cb0ef41Sopenharmony_ci    case kSpDwarfCode:
461cb0ef41Sopenharmony_ci      return "sp";
471cb0ef41Sopenharmony_ci    default:
481cb0ef41Sopenharmony_ci      UNIMPLEMENTED();
491cb0ef41Sopenharmony_ci  }
501cb0ef41Sopenharmony_ci}
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci#endif
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_ci}  // namespace internal
551cb0ef41Sopenharmony_ci}  // namespace v8
56