From 258281d8ac7b6ab61d64948340038e5f6692e3c0 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 19 Jan 2010 06:22:22 +0000 Subject: [PATCH] fix parsing .comm directives on systems which do not represent alignments as a power of 2. This fixes MC/AsmParser/directive_comm.s git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93867 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-mc/AsmLexer.h | 4 +++- tools/llvm-mc/AsmParser.cpp | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/llvm-mc/AsmLexer.h b/tools/llvm-mc/AsmLexer.h index ce292f66b12..c0b32232abb 100644 --- a/tools/llvm-mc/AsmLexer.h +++ b/tools/llvm-mc/AsmLexer.h @@ -62,7 +62,9 @@ public: bool EnterIncludeFile(const std::string &Filename); void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const; - + + const MCAsmInfo &getMAI() const { return MAI; } + private: int getNextChar(); AsmToken ReturnError(const char *Loc, const std::string &Msg); diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp index d4af4bd0df6..0e7c3443d5a 100644 --- a/tools/llvm-mc/AsmParser.cpp +++ b/tools/llvm-mc/AsmParser.cpp @@ -1278,6 +1278,13 @@ bool AsmParser::ParseDirectiveComm(bool IsLocal) { Pow2AlignmentLoc = Lexer.getLoc(); if (ParseAbsoluteExpression(Pow2Alignment)) return true; + + // If this target takes alignments in bytes (not log) validate and convert. + if (Lexer.getMAI().getAlignmentIsInBytes()) { + if (!isPowerOf2_64(Pow2Alignment)) + return Error(Pow2AlignmentLoc, "alignment must be a power of 2"); + Pow2Alignment = Log2_64(Pow2Alignment); + } } if (Lexer.isNot(AsmToken::EndOfStatement)) -- 2.34.1