Skip to content

Commit

Permalink
Merge pull request #47 from Decompollaborate/develop
Browse files Browse the repository at this point in the history
1.8.0
  • Loading branch information
AngheloAlf authored Nov 12, 2023
2 parents e0d8003 + be56a71 commit 15011a8
Show file tree
Hide file tree
Showing 25 changed files with 416 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pypi_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/cibuildwheel@v2.12.3
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_ARCHS_WINDOWS: "auto"
CIBW_ARCHS_LINUX: "auto"
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.8.0] - 2023-11-12

### Added

- Add `flag_r5900DisasmAsData` member to the `Instruction` class.
- This flag allows to fine-tune R5900 instruction set that are affected by
the global `gnuMode` option.
- Currently these instructions are: `trunc.w.s`, `cvt.w.s`, `vclipw` and
`vsqrt`.
- `TrinaryValue.TRUE` forces the instruction to be disassembled as data.
- `TrinaryValue.FALSE` bypasses the global checks for disassembling a word
as data. A word will still be disassembled as data if it can't be decoded.
- `TrinaryValue.NONE` leaves this decision to the global settings.
- Add `flag_r5900UseDollar` member to the `Instruction` class.
- `TrinaryValue.TRUE` forces the use of dollar signs ($) on R5900's VU
instructions.
- `TrinaryValue.FALSE` forces disassembling to not use of dollar signs ($) on
R5900's VU instructions.
- `TrinaryValue.NONE` leaves this decision to the global settings.

## [1.7.10] - 2023-09-24

### Added
Expand Down Expand Up @@ -469,6 +489,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- First version

[unreleased]: https://github.com/Decompollaborate/rabbitizer/compare/master...develop
[1.8.0]: https://github.com/Decompollaborate/rabbitizer/compare/1.7.10...1.8.0
[1.7.10]: https://github.com/Decompollaborate/rabbitizer/compare/1.7.9...1.7.10
[1.7.9]: https://github.com/Decompollaborate/rabbitizer/compare/1.7.8...1.7.9
[1.7.8]: https://github.com/Decompollaborate/rabbitizer/compare/1.7.7...1.7.8
[1.7.7]: https://github.com/Decompollaborate/rabbitizer/compare/1.7.6...1.7.7
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[package]
name = "rabbitizer"
# Version should be synced with include/common/RabbitizerVersion.h
version = "1.7.10"
version = "1.8.0"
edition = "2021"
authors = ["Anghelo Carvajal <[email protected]>"]
description = "MIPS instruction decoder"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CFLAGS := -fPIC -fno-common
CXXFLAGS := -fPIC -fno-common
LDFLAGS := -Lbuild -lrabbitizer
LDXXFLAGS := -Lbuild -lrabbitizerpp
WARNINGS := -Wall -Wextra -Wpedantic
WARNINGS := -Wall -Wextra -Wpedantic -Wunused-value
WARNINGS += -Wformat=2 -Wundef
# WARNINGS += -Wconversion
WARNINGS += -Werror=vla -Werror=switch -Werror=implicit-fallthrough -Werror=unused-function
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,16 @@ See this package at <https://pypi.org/project/rabbitizer/>.

### Rust bindings

Add this crate to your `Cargo.toml` via:
Add this crate to your project with Cargo:

```bash
cargo add rabbitizer
```

Or you can add it manually to your `Cargo.toml`:

```toml
[build]
rabbitizer = "1.5.8"
rabbitizer = "1.8.0"
```

See this crate at <https://crates.io/crates/rabbitizer>.
Expand Down
15 changes: 15 additions & 0 deletions cplusplus/include/common/Utils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* SPDX-FileCopyrightText: © 2023 Decompollaborate */
/* SPDX-License-Identifier: MIT */

#ifndef RABBITIZER_UTILS_HPP
#define RABBITIZER_UTILS_HPP

namespace rabbitizer {
enum class TrinaryValue {
NONE,
FALSE,
TRUE,
};
}

#endif
13 changes: 13 additions & 0 deletions cplusplus/include/instructions/InstructionBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "instructions/RabbitizerInstruction.h"

#include "common/Utils.hpp"

#include "instructions/Registers.hpp"
#include "instructions/OperandType.hpp"
#include "instructions/InstrId.hpp"
Expand Down Expand Up @@ -145,6 +147,17 @@ namespace rabbitizer {
/* setters */


/* flags */

TrinaryValue FlagGet_r5900DisasmAsData() const;
void FlagSet_r5900DisasmAsData(TrinaryValue value);

TrinaryValue FlagGet_r5900UseDollar() const;
void FlagSet_r5900UseDollar(TrinaryValue value);

/* flags */


/* more getters */

uint32_t getRaw() const;
Expand Down
2 changes: 2 additions & 0 deletions cplusplus/include/rabbitizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "common/RabbitizerVersion.h"
#include "common/RabbitizerConfig.h"

#include "common/Utils.hpp"

#include "instructions/OperandType.hpp"
#include "instructions/InstrId.hpp"
//#include "instructions/InstrSuffix.hpp"
Expand Down
18 changes: 18 additions & 0 deletions cplusplus/src/instructions/InstructionBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,24 @@ void InstructionBase::Set_stype(uint8_t val) {

/* setters */

/* flags */

TrinaryValue InstructionBase::FlagGet_r5900DisasmAsData() const {
return static_cast<TrinaryValue>(RAB_INSTR_FLAGS_GET_r5900DisasmAsData(&this->instr));
}
void InstructionBase::FlagSet_r5900DisasmAsData(TrinaryValue value) {
RAB_INSTR_FLAGS_SET_r5900DisasmAsData(&this->instr, static_cast<RabTrinaryValue>(value));
}

TrinaryValue InstructionBase::FlagGet_r5900UseDollar() const {
return static_cast<TrinaryValue>(RAB_INSTR_FLAGS_GET_r5900UseDollar(&this->instr));
}
void InstructionBase::FlagSet_r5900UseDollar(TrinaryValue value) {
RAB_INSTR_FLAGS_SET_r5900UseDollar(&this->instr, static_cast<RabTrinaryValue>(value));
}

/* flags */

/* more getters */

uint32_t InstructionBase::getRaw() const {
Expand Down
4 changes: 2 additions & 2 deletions include/common/RabbitizerVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ extern "C" {

// Header version
#define RAB_VERSION_MAJOR 1
#define RAB_VERSION_MINOR 7
#define RAB_VERSION_PATCH 10
#define RAB_VERSION_MINOR 8
#define RAB_VERSION_PATCH 0

#define RAB_VERSION_STR RAB_STRINGIFY(RAB_VERSION_MAJOR) "." RAB_STRINGIFY(RAB_VERSION_MINOR) "." RAB_STRINGIFY(RAB_VERSION_PATCH)

Expand Down
5 changes: 5 additions & 0 deletions include/common/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ extern "C" {
# define UNREACHABLE
#endif

typedef enum RabTrinaryValue {
RAB_TRINARY_VAL_NONE,
RAB_TRINARY_VAL_FALSE,
RAB_TRINARY_VAL_TRUE,
} RabTrinaryValue;

#define ARRAY_COUNT(arr) (sizeof(arr) / sizeof((arr)[0]))

Expand Down
38 changes: 38 additions & 0 deletions include/instructions/RabbitizerInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,37 @@ typedef struct RabbitizerInstruction {
bool _handwrittenCategory;
bool inHandwrittenFunction;
RabbitizerInstrCategory category;

/**
* Flags are bitpacked, refer to the `RAB_INSTR_FLAGS_` macros to access them.
*
* Bit usage:
* - Bits 0 ~ 1: `r5900DisasmAsData`. Value of the `RabTrinaryValue` enum.
* - `RAB_TRINARY_VAL_TRUE` forces the instruction to be disassembled as data.
* - `RAB_TRINARY_VAL_FALSE` bypasses the global checks for disassembling a word as data. A word will still be disassembled as data if it can't be decoded.
* - `RAB_TRINARY_VAL_NONE` leaves this decision to the global settings.
* - Defaults to `RAB_TRINARY_VAL_NONE`
* - Bit 2 ~ 3: `r5900UseDollar`. Value of the `RabTrinaryValue` enum.
* - `RAB_TRINARY_VAL_TRUE` forces the use of dollar signs ($) on R5900's VU instructions
* - `RAB_TRINARY_VAL_FALSE` forces disassembling to not use of dollar signs ($) on R5900's VU instructions
* - `RAB_TRINARY_VAL_NONE` leaves this decision to the global settings.
* - Defaults to `RAB_TRINARY_VAL_NONE`
* - Bit 4 ~ 5: Reserved for future use.
* - Bit 6 ~ 7: Reserved for future use.
* - Bit 8 ~ 9: Reserved for future use.
* - Bit 10 ~ 11: Reserved for future use.
* - Bit 12 ~ 13: Reserved for future use.
* - Bit 14 ~ 15: Reserved for future use.
* - Bit 16 ~ 17: Reserved for future use.
* - Bit 18 ~ 19: Reserved for future use.
* - Bit 20 ~ 21: Reserved for future use.
* - Bit 22 ~ 23: Reserved for future use.
* - Bit 24 ~ 25: Reserved for future use.
* - Bit 26 ~ 27: Reserved for future use.
* - Bit 28 ~ 29: Reserved for future use.
* - Bit 30 ~ 31: Reserved for future use.
*/
uint32_t flags;
} RabbitizerInstruction;


Expand Down Expand Up @@ -114,6 +145,13 @@ typedef struct RabbitizerInstruction {
#define RAB_INSTR_PACK_stype(word, value) (BITREPACK((word), (value), 6, 5))


#define RAB_INSTR_FLAGS_GET_r5900DisasmAsData(self) (RabTrinaryValue)(SHIFTR((self)->flags, 0, 2))
#define RAB_INSTR_FLAGS_SET_r5900DisasmAsData(self, value) ((self)->flags = BITREPACK((self)->flags, (value), 0, 2))

#define RAB_INSTR_FLAGS_GET_r5900UseDollar(self) (RabTrinaryValue)(SHIFTR((self)->flags, 2, 2))
#define RAB_INSTR_FLAGS_SET_r5900UseDollar(self, value) ((self)->flags = BITREPACK((self)->flags, (value), 2, 2))


NON_NULL(1)
void RabbitizerInstruction_init(RabbitizerInstruction *self, uint32_t word, uint32_t vram);
NON_NULL(1)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[project]
name = "rabbitizer"
# Version should be synced with include/common/RabbitizerVersion.h
version = "1.7.10"
version = "1.8.0"
description = "MIPS instruction decoder"
# license = "MIT"
readme = "README.md"
Expand Down
13 changes: 13 additions & 0 deletions rabbitizer/TrinaryValue.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: © 2023 Decompollaborate
# SPDX-License-Identifier: MIT

# Automatically generated. DO NOT MODIFY

from __future__ import annotations
from .Enum import Enum
class TrinaryValue:
NONE: Enum
FALSE: Enum
TRUE: Enum
3 changes: 3 additions & 0 deletions rabbitizer/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ from .RegCop1N32 import *
from .RegCop1N64 import *

from .Abi import *

from .TrinaryValue import *

from .Config import *

from .rabbitizer import *
Expand Down
24 changes: 24 additions & 0 deletions rabbitizer/enums/rabbitizer_enum_TrinaryValue.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* SPDX-FileCopyrightText: © 2023 Decompollaborate */
/* SPDX-License-Identifier: MIT */

#include "enums_utils.h"
#include "common/Utils.h"

#define RAB_DEF_TRINARYVALUE(name) { "TrinaryValue", #name , RAB_TRINARY_VAL_##name, false, NULL },

RabbitizerEnumMetadata rabbitizer_enum_TrinaryValue_enumvalues[] = {
RAB_DEF_TRINARYVALUE(NONE)
RAB_DEF_TRINARYVALUE(FALSE)
RAB_DEF_TRINARYVALUE(TRUE)

{ 0 },
};

#undef RAB_DEF_TRINARYVALUE


static PyMethodDef rabbitizer_enum_TrinaryValue_methods[] = {
{ 0 },
};

DEF_ENUM(TrinaryValue, "")
19 changes: 19 additions & 0 deletions rabbitizer/rabbitizer.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ from __future__ import annotations

from .Enum import Enum
from .InstrCategory import InstrCategory
from .TrinaryValue import TrinaryValue


class Instruction:
Expand Down Expand Up @@ -60,6 +61,24 @@ class Instruction:
inHandwrittenFunction: bool = False
"""Boolean value indicating if the current instruction is used on a handwritten function. This is intended to be determined by the user."""

flag_r5900DisasmAsData: Enum = TrinaryValue.NONE
"""Flag to override the r5900DisasmAsData global configuration.
- This flag allows to fine-tune R5900 instruction set that are affected by the global `gnuMode` option.
- Currently these instructions are: `trunc.w.s` (r5900 mode), `cvt.w.s` (r5900 mode), `vclipw` and `vsqrt`.
- `TrinaryValue.TRUE` forces the instruction to be disassembled as data.
- `TrinaryValue.FALSE` bypasses the global checks for disassembling a word as data. A word will still be disassembled as data if it can't be decoded.
- `TrinaryValue.NONE` leaves this decision to the global settings.
"""
flag_r5900UseDollar: Enum = TrinaryValue.NONE
"""Flag to override the disasmAsData global configuration.
- `TrinaryValue.TRUE` forces the use of dollar signs ($) on R5900's VU instructions.
- `TrinaryValue.FALSE` forces disassembling to not use of dollar signs ($) on R5900's VU instructions.
- `TrinaryValue.NONE` leaves this decision to the global settings.
"""


def __init__(self, word: int, vram: int=0, category: Enum=InstrCategory.CPU) -> None: ...

Expand Down
2 changes: 2 additions & 0 deletions rabbitizer/rabbitizer_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ static ModuleAttributes rabbitizer_module_attributes[] = {
MODULE_ATTRIBUTE_ENUM(RegCop1N32),
MODULE_ATTRIBUTE_ENUM(RegCop1N64),

MODULE_ATTRIBUTE_ENUM(TrinaryValue),

MODULE_ATTRIBUTE_TYPE(Instruction),
MODULE_ATTRIBUTE_TYPE(LoPairingInfo),
MODULE_ATTRIBUTE_TYPE(TrackedRegisterState),
Expand Down
2 changes: 2 additions & 0 deletions rabbitizer/rabbitizer_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ DECL_ENUM(RegCop1O32)
DECL_ENUM(RegCop1N32)
DECL_ENUM(RegCop1N64)

DECL_ENUM(TrinaryValue)

#endif
Loading

0 comments on commit 15011a8

Please sign in to comment.