From ca0e1b5593452a80d9a37d50b75124b6d40366b7 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 27 Feb 2023 20:08:24 +0800 Subject: [PATCH] work save --- RedPandaIDE/RedPandaIDE.pro | 8 ++++++++ RedPandaIDE/debugger.cpp | 7 +++---- RedPandaIDE/mainwindow.cpp | 9 ++++----- libs/qsynedit/qsynedit.pro | 8 ++++++++ libs/qsynedit/qsynedit/syntaxer/asm.cpp | 11 ++++++++++- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 84e2a874..108b50a9 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -13,6 +13,14 @@ isEmpty(APP_VERSION) { APP_VERSION = 2.15 } +contains(QMAKE_HOST.arch, x86_64):{ + contains(QMAKE_HOST.arch, x86_64):{ + DEFINES += ARCH_X86_64=1 + } else : { + DEFINES += ARCH_X86=1 + } +} + macos: { # This package needs to be installed via homebrew before we can compile it INCLUDEPATH += \ diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index 3a824e21..f45870d7 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -2648,9 +2648,8 @@ bool WatchModel::hasChildren(const QModelIndex &parent) const RegisterModel::RegisterModel(QObject *parent):QAbstractTableModel(parent) { - QString cpuArch=QSysInfo::currentCpuArchitecture(); - if (cpuArch=="x86_64" || cpuArch=="i386") { -//https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html +#if defined(ARCH_X86_64) || defined(ARCH_X86) + //https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html mRegisterDescriptions.insert("rax",tr("64-bit")+" "+tr("Accumulator for operands and results data")); mRegisterDescriptions.insert("rbx",tr("64-bit")+" "+tr("Pointer to data in the DS segment")); mRegisterDescriptions.insert("rcx",tr("64-bit")+" "+tr("Counter for string and loop operations")); @@ -2782,7 +2781,7 @@ RegisterModel::RegisterModel(QObject *parent):QAbstractTableModel(parent) mRegisterDescriptions.insert("mxscr",tr("SSE status and control")); - } +#endif } int RegisterModel::rowCount(const QModelIndex &) const diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 8e11af16..66c7b08b 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -415,17 +415,16 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->menuProject, &QMenu::aboutToShow, this, &MainWindow::updateProjectActions); - QString cpuArch = QSysInfo::currentCpuArchitecture(); - if (cpuArch == "i386") { +#ifdef ARCH_X86 ui->actionIA_32_Assembly_Language_Reference_Manual->setVisible(true); ui->actionx86_Assembly_Language_Reference_Manual->setVisible(false); - } else if (cpuArch=="x86_64") { +#elif defined(ARCH_X86_64) ui->actionIA_32_Assembly_Language_Reference_Manual->setVisible(true); ui->actionx86_Assembly_Language_Reference_Manual->setVisible(true); - } else { +#else ui->actionIA_32_Assembly_Language_Reference_Manual->setVisible(false); ui->actionx86_Assembly_Language_Reference_Manual->setVisible(false); - } +#endif ui->actionEGE_Manual->setVisible(pSettings->environment().language()=="zh_CN"); ui->actionDocument->setVisible(pSettings->environment().language()=="zh_CN"); diff --git a/libs/qsynedit/qsynedit.pro b/libs/qsynedit/qsynedit.pro index dff82950..925b7d32 100644 --- a/libs/qsynedit/qsynedit.pro +++ b/libs/qsynedit/qsynedit.pro @@ -5,6 +5,14 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++17 CONFIG += nokey CONFIG += staticlib +contains(QMAKE_HOST.arch, x86_64):{ + contains(QMAKE_HOST.arch, x86_64):{ + DEFINES += ARCH_X86_64=1 + } else : { + DEFINES += ARCH_X86=1 + } +} + win32: { DEFINES += _WIN32_WINNT=0x0601 diff --git a/libs/qsynedit/qsynedit/syntaxer/asm.cpp b/libs/qsynedit/qsynedit/syntaxer/asm.cpp index 26d544a3..6db6cf82 100644 --- a/libs/qsynedit/qsynedit/syntaxer/asm.cpp +++ b/libs/qsynedit/qsynedit/syntaxer/asm.cpp @@ -24,6 +24,7 @@ QSet ASMSyntaxer::InstructionNames; QMap ASMSyntaxer::Instructions; const QSet ASMSyntaxer::Registers { +#if defined(ARCH_X86_64) || defined(ARCH_X86) "ah","al","ax","eax", "bh","bl","bx","ebx", "ch","cl","cx","ecx", @@ -50,9 +51,11 @@ const QSet ASMSyntaxer::Registers { "xmm4","xmm5","xmm6","xmm7", "xmm8","xmm9","xmm10","xmm11", "xmm12","xmm13","xmm14","xmm15", +#endif }; const QSet ASMSyntaxer::ATTRegisters { +#if defined(ARCH_X86_64) || defined(ARCH_X86) "%ah","%al","%ax","%eax", "%bh","%bl","%bx","%ebx", "%ch","%cl","%cx","%ecx", @@ -79,16 +82,20 @@ const QSet ASMSyntaxer::ATTRegisters { "%xmm4","%xmm5","%xmm6","%xmm7", "%xmm8","%xmm9","%xmm10","%xmm11", "%xmm12","%xmm13","%xmm14","%xmm15", +#endif }; const QSet ASMSyntaxer::Directives { +#if defined(ARCH_X86_64) || defined(ARCH_X86) "section","global","extern","segment", "db","dw","dd","dq","dt","do","dy","dz", "resb","resw","resd","resq","rest","reso","resy","resz", "equ","times","word","dword","byte","tword" +#endif }; const QSet ASMSyntaxer::ATTDirectives { +#if defined(ARCH_X86_64) || defined(ARCH_X86) ".abort",".align",".altmacro",".ascii", ".asciz",".attach",".balign",".bss", ".bundle",".byte",".comm",".data", @@ -117,6 +124,7 @@ const QSet ASMSyntaxer::ATTDirectives { ".title", ".tls", ".type", ".uleb128", ".val",".version", ".vtable", ".warning",".weak",".weakref",".word", ".zero",".2byte",".4byte",".8byte" +#endif }; ASMSyntaxer::ASMSyntaxer(bool isATT): @@ -335,6 +343,7 @@ void ASMSyntaxer::initData() if (Instructions.isEmpty()) { // https://docs.oracle.com/cd/E19120-01/open.solaris/817-5477/ennbz/index.html //Data Transfer Instruction +#if defined(ARCH_X86_64) || defined(ARCH_X86) Instructions.insert("bswap",QObject::tr("byte swap.")); Instructions.insert("bswapl",QObject::tr("byte swap.")); Instructions.insert("bswapq",QObject::tr("byte swap.")); @@ -1090,7 +1099,7 @@ void ASMSyntaxer::initData() Instructions.insert("movnti",QObject::tr("non-temporal store of a doubleword from a general-purpose register into memory.")); Instructions.insert("movntpd",QObject::tr("non-temporal store of two packed double-precision floating-point values from an xmm register into memory.")); Instructions.insert("pause",QObject::tr("improves the performance of spin-wait loops.")); - +#endif InstructionNames=QSet(Instructions.keyBegin(),Instructions.keyEnd()); } }