File tree 3 files changed +26
-1
lines changed
3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 25
25
#include " dmd/mangle.h"
26
26
#include " gen/llvmhelpers.h" // printLabelName
27
27
#include < cctype>
28
+ #include " llvm/ADT/StringRef.h"
28
29
29
30
#ifndef ASM_X86_64
30
31
namespace AsmParserx8632 {
@@ -3703,7 +3704,15 @@ struct AsmProcessor {
3703
3704
// check for reg first then dotexp is an error?
3704
3705
if (e->op == EXP::identifier) {
3705
3706
for (int i = 0 ; i < N_Regs; i++) {
3706
- if (ident == regInfo[i].ident ) {
3707
+ const auto reg = regInfo[i].ident ;
3708
+ const auto matchesRegister = stmt->caseSensitive ?
3709
+ ident == reg :
3710
+ #if LDC_LLVM_VER >= 1300
3711
+ reg && llvm::StringRef (ident->toChars ()).equals_insensitive (reg->toChars ());
3712
+ #else
3713
+ reg && llvm::StringRef (ident->toChars ()).equals_lower (reg->toChars ());
3714
+ #endif
3715
+ if (matchesRegister) {
3707
3716
if (static_cast <Reg>(i) == Reg_ST &&
3708
3717
token->value == TOK::leftParenthesis) {
3709
3718
nextToken ();
Original file line number Diff line number Diff line change @@ -114,8 +114,11 @@ Statement *asmSemantic(AsmStatement *s, Scope *sc) {
114
114
// this is DMD-style asm
115
115
sc->func ->hasReturnExp |= 32 ;
116
116
117
+ const auto caseSensitive = s->caseSensitive ;
118
+
117
119
auto ias = createInlineAsmStatement (s->loc , s->tokens );
118
120
s = ias;
121
+ s->caseSensitive = caseSensitive;
119
122
120
123
bool err = false ;
121
124
llvm::Triple const &t = *global.params .targetTriple ;
Original file line number Diff line number Diff line change
1
+ // DMD supports case-insensitive register operands for x86 assembly in C files, when targeting Windows.
2
+ // Additionally, a new-line can be used to terminate an instruction.
3
+
4
+ // REQUIRES: Windows && target_X86
5
+ // RUN: %ldc -mtriple=i686-pc-windows-msvc -c %s
6
+
7
+ unsigned int subtract (unsigned int a , unsigned int b ) {
8
+ __asm {
9
+ mov eax , dword ptr [a ]
10
+ mov eDX , dword ptr [b ]
11
+ sub Eax , edx
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments